eolymp
Competitions

Хвиля

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 (5n20, 1x1, y1, x2, y2n). 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).

Time limit 1 second
Memory limit 122.17 MiB
Input example #1
5
1 1
3 1
Output example #1
2