Battle Royale#11626

Battle Royale

1 second
128 megabytes
Medium

Battle Royale games are the current trend in video games, and Gamers Concealed Punching Circles (GCPC) is the most popular game of them all. The game takes place in an area that, for the sake of simplicity, can be thought of as a two-dimensional plane. Movement and positioning are a substantial part of the gameplay, but getting to a desired location can be dangerous. You are confident in your ability to handle the other players; however, while you are walking to your destination, there are two hazards posed by the game itself:

You want to move from one spot on the map to another, but the direct path to your destination is blocked by the red circle, so you need to find a way around it. Can you find the shortest path that avoids all hazards by never leaving the blue or entering the red circle? Touching the boundaries of the circles is fine, as long as you do not cross them.

Input

The first line contains two integers x_c, y_c specifying your current location.

The second line contains two integers x_d, y_d specifying your destination.

The next line specifies the center x_b, y_b and radius r_b of the blue circle.

The next line specifies the center x_r, y_r and radius r_r of the red circle.

All coordinates have an absolute value of at most , and 1 \leq r_b, r_r \leq 1000. The red circle is strictly inside the blue circle. Your current location and destination are strictly inside the blue circle and strictly outside of the red circle, and the direct path between them is blocked by the red circle.

Output

Output the length of the shortest path that does not leave the blue or enter the red circle. The output must be accurate up to a relative or absolute error (whichever is lower) of 10^{-7}.

Examples

Example 1

Loading
Loading