The equilateral triangle $ABC$ has sides of integer length $N$. The triangle is completely divided (by drawing lines parallel to the sides of the triangle) into equilateral triangular cells of side length $1$.
A continuous route is chosen, starting inside the cell with vertex $A$ and always crossing from one cell to another through an edge shared by the two cells. No cell is visited more than once. Find, with proof, the greatest number of cells which can be visited.
I think I've managed to prove that the number of cells in the triangle is equal to $N^2$, however I'm not sure how rigorous this was. I've spotted that the correct answer seems to be $N^2-N+1$, though I'm not able to prove it. I've been looking at how certain cells become dead ends, but as you go further down things become more complicated and there is no clear proof in sight.
Can anyone come up with a hint or full proof. Thanks in advance.