Problems
One knight
One knight
The hungry chess knight stays in the cell (x1
, y1
) of the chessboard of size n × n. He wants to get into the cell (x2
, y2
), where delicious chess grass grows. What is the least number of moves he has to do?
Input
Contains five numbers: n, x1
, y1
, x2
, y2
(5 ≤ n ≤ 20, 1 ≤ x1
, y1
, x2
, y2
≤ n). The upper left cell of the board has coordinates (1, 1), the bottom right - (n, n).
Output
Print the minimum number of moves to go from (x1
, y1
) to (x2
, y2
).
Input example #1
5 1 1 3 1
Output example #1
2