All Tracks Algorithms Greedy Algorithms Basics of Greedy Algorithms Problem

Harry Potter and the Sorcerer's Stone
/

Breadth First Search, Dijkstra's Algorithm

Problem
Editorial
Analytics

Do you remember Harry, Ron and Hermione had to play the wizard chess to get to Voldemort, sorry, "You know who", in Harry Potter and the Sorcerer's Stone? Well, Harry needs to knock Ron's king out to get to "You know who" by using only his knight. As the time is running out, he needs to find out the minimum number of steps in which he can knock Ron's king out by using his knight, assuming Ron's king stays in the same position throughout the game.

Input

The only line contains four numbers x1,y1,x2,y2. x1,y1 are the coordinates of Harry's knight. x2,y2 are the coordinates of Ron's king.

Output

Print the minimum number of moves in one line.

Constraints

1 <= x1,y1,x2,y2 <=8

SAMPLE INPUT
2 1 6 5
SAMPLE OUTPUT
4
Explanation

He needs to make 4 minimum moves to knock the king out. Given in the image is one such path.

enter image description here

Time Limit: 1.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB

Best Submission

Similar Problems

Contributors

This Problem was Asked in

Initializing Code Editor...
Notifications
View All Notifications

?