# Spider and Fly - 2

Medium

Execution time limit is 1 second

Runtime memory usage limit is 64 megabytes

In the empty rectangular room with the length А, the width В and the height С the fly fall onto the floor and fall a sleep. A spider which is lying on one of the walls or on the floor, or on the ceiling, starts moving to the fly by the shortest path.

What distance will it cover?

## Input

The first line contains the sizes of the room А, В, С. The second line contains the coordinates of the fly on the floor X1, Y1, (0 ≤ X1 ≤ A, 0 ≤ Y1 ≤ B). The third line contains the coordinates of the spider X2, Y2, Z2, (0 ≤ X2 ≤ A, 0 ≤ Y2 ≤ B, 0 ≤ Z2 ≤ C). All input values are integer nonnegative numbers less then or equal to 500.

## Output

The only number – the distance which will be covered by the spider with two digits after the decimal point.

## Examples

Input #37

Answer #37

Submissions 2K

Acceptance rate 8%