You have an idea for a board game. The board is a grid of 32001×32001 numbered squares. The centre square holds the number 1, and every other number sits on an anticlockwise spiral that grows outwards. The spiral first moves downwards, then to the right, then upwards, then to the left, then downwards again, and so on. The figure below shows the middle 25 squares, and the figure in the hint shows the middle 441 squares.

Figure A.1: the middle 25 squares.
A player moves one square at a time, up, down, left, or right. Given the numbers of two squares, find the smallest number of moves needed to get from one to the other.