Description

One day while grazing in particularly deep hay, Betsy discovered four magic cow shoes! She donned them and found that they enabled her to jump around the pasture which, of course, is subdivided into a convenient grid with R rows (1 <= R <= 50) and C columns (1 <= C <= 50). The shoes enabled her to jump two different ways: both like a chess game knight and in another pattern she'd never seen before. She noticed that she jumped like a knight on her first, third, fifth, and odd-numbered moves while she jumped in the new way on the second, fourth, sixth, and even-numbered moves. Here is a map of the possible move patterns she discovered:

Knight (Odd moves)     Other (Even moves)
   . . K . K . .         . . . O . . .
   . K . . . K .         . . . . . . .
   . . . B . . .         . O . B . O .
   . K . . . K .         . . . . . . .
   . . K . K . .         . . . O . . .
When Betsy starts at the 'B', depending on whether her next move is an odd or even one, she can jump to any one of the 'K's or 'O's.

Realizing she can now move about the pasture much more quickly, Betsy wonders how long it will take her to jump using the magic shoes all the way over to the Milky Way candy bar Farmer John accidentally dropped on his recent visit to the cows.

Given the size of the field along with the locations of Betsy and the candy bar, determine the minimum number of magic shoe jumps required for Betsy to land on the square with the candy bar. She is not allowed to jump outside the pasture but is sure that it is always possible to get to the candy bar.

Input

The input file contains multiple test cases, for each test case:

* Line 1: Two space-separated integers: respectively R and C.

* Line 2: Two space-separated integers: respectively the row and column of Betsy's starting location.

* Line 3: Two space-separated integers: respectively the row and column of the candy bar.

Process till EOF.

Output

For each test case, output:

* Line 1: A single integer that is the minimum number of jumps using the magic shoes until Betsy lands on the candy bar.

Sample Input

4 5
4 1
4 3

Sample Output

3

Source

USACO 2006 March