LearnPy Hub
← Arena
AdvancedRating 1500

Knight's Journey

On an n×n chessboard, print the minimum number of knight moves from (x1, y1) to (x2, y2) (1-based).

Input

n, then 'x1 y1 x2 y2'.

Output

A number.

Sample 1

Input
8
1 1 8 8
Output
6

Sample 2

Input
8
1 1 1 1
Output
0
solution.py
Output appears here
Knight's Journey · Python Arena problem · LearnPy Hub