e-olymp
Problems

Spider and Fly - 2

Spider and Fly - 2

prb74

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, (0X1A, 0Y1B). The third line contains the coordinates of the spider X2, Y2, Z2, (0X2A, 0Y2B, 0Z2C). 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.

Time limit 1 second
Memory limit 64 MiB
Input example #37
4 7 3
2 1
3 7 2
Output example #37
8.06