570. Harry's Chess Challenge

0

Easy

Given a chessboard, determine the minimum number of steps a knight must take to reach a specified destination from a given starting point.

The knight's movement is shown in the diagram below:

Input Format

An integer n indicating the size of the chessboard

Coordinates of the starting point and the destination.

Coordinates of the starting point and the destination.

Output Format

An integer representing the minimum number of steps required.

Example

Input

8
7 0
0 7

Output

6

Constraints

0<=n<=50

Loading...

View Submissions

Console