Spider and Fly - 2#74

Spider and Fly - 2

1 second
64 megabytes
Medium

A fly is resting on the floor of an empty rectangular room with length , width , and height . A spider, located on one of the walls, the floor, or the ceiling, moves toward the fly along the shortest possible path.

The spider can move only along the surfaces of the room, or it may descend straight down from the ceiling to the floor on its web, but only at a right angle.

What is the minimum distance the spider must travel to reach the fly?

Input

The first line contains the dimensions of the room: , , .

The second line contains the coordinates of the fly on the floor: X_1, Y_1 (0 \leq X_1 \leq A, 0 \leq Y_1 \leq B).

The third line contains the coordinates of the spider: X_2, Y_2, Z_2 (0 \leq X_2 \leq A, 0 \leq Y_2 \leq B, 0 \leq Z_2 \leq C).

All input values are non-negative integers not exceeding .

Output

Print a single number — the distance the spider must travel, rounded to two decimal places.

Examples

Example

Input
10 10 10
2 3
7 8 5
Output
12.81

Example 37

Loading
Loading