Particle Collision

Three equal circles at rest; particle 1 moves along a given vector and transfers motion on contact. Decide which of five collision chains occurs.

Medium6GeometrySimulationMathImplementationNo attempts yetTime limit1sMemory limit512 MB

Problem

Building a particle collider is hard, and running one experiment on it costs a lot. Checking an idea in simulation first is cheaper than testing it on real hardware. Write a simple simulator for the setup below.

The system holds exactly three particles. All of them stay on an infinite plane, so each one is a circle. The position of particle ii is given only by the coordinates xix_i and yiy_i of its center (1i31 \le i \le 3). The three particles share the same radius rr, and all of them are at rest at the start.

Once the experiment starts, particle 1 moves in the direction of the vector (xv,yv)(x_v, y_v). When particle ii touches particle jj, particle jj starts moving in the direction perpendicular to the common tangent at the contact point, which points away from particle ii. At that instant particle ii disappears and turns into radiation. A moving particle that touches no other particle keeps moving forever.

The simulator has to tell these five outcomes apart.

  1. Particle 1 touches particle 2, and particle 2 then touches particle 3.
  2. Particle 1 touches particle 3, and particle 3 then touches particle 2.
  3. Particle 1 touches particle 2, and particle 2 moves forever.
  4. Particle 1 touches particle 3, and particle 3 moves forever.
  5. Particle 1 moves forever.

Input

The input has four lines. Each of the first three lines holds two integers xix_i and yiy_i (xi,yi1000|x_i|, |y_i| \le 1000), describing particle 1, particle 2, and particle 3 in that order. The fourth line holds three integers xvx_v, yvy_v, and rr (xv,yv1000|x_v|, |y_v| \le 1000, 0<r500 < r \le 50). The vector (xv,yv)(x_v, y_v) is not the zero vector.

No two particles touch or overlap at the start, and the distance between the centers of particle 2 and particle 3 is greater than 4r4r.

Output

Print the number of the outcome listed above as a single integer from 1 to 5.

Compute carefully. The outcome is guaranteed to stay the same if the initial vector (xv,yv)(x_v, y_v) is rotated by one degree in either direction.