A cemetery has a form of rectangle. There are N rows of graves, M ones in each row. The cemetery is enclosed with a high fence.
Lara Croft has penetrated into the cemetery through the sap at the Northwestern corner. It takes one night for Lara to dig a subway under one of the graves. If there is an intact grave straight ahead then Lara will lengthen the passage during the next night and will ravage the grave. If there is a cemetery fence or a ravaged grave on the way, then Lara will turn 90 degrees clockwise and will continue with her questionable affairs.
Treasures are located in two graves only. And we exactly know in which ones. But Lara doesn't. Lara has bought a package of champagne today. It means, that today she has found one of those graves. We wonder how long will it take her to find the other one?
Input
The first line contains integers N and M that are the sizes of the cemetery (2 ≤ N, M ≤ 100).
The North-Western grave has coordinates (1, 1) and the South-Eastern one — (N, M). Lara starts with the grave (1, 1) moving to the East, i.e. towards the grave (1, 2).
The second and the third lines contain integers (r1, c1) and (r2, c2) that are the treasure graves coordinates (1 ≤ ri ≤ N; 1 ≤ ci ≤ M). The order of graves is arbitrary, i.e. Lara may reach the first or the second grave earlier.
Output
Output an amount of days that Lara will spend reaching for another grave with treasures.
Sample
Notes
In the example Lara will find the treasures on the 9'th and the 15'th days.
Problem Author: Stanislav Vasilyev
Problem Source: IX Urals Programming Contest. Yekaterinburg, April 19-24, 2005