It may be helpful it some circumstances to look at some other ways of seeing the challenge. Imagine you are looking through a small strange window and can only see part of the town square ( which maybe a rectangle). You may see the path of a friend going across from corner to corner in a straight line. So what size can the rectangle be and how many tiles are cut through?

or maybe in another town through another strnage window you see the path is like this;

So what size can the rectangle be and how many tiles are cut through?