Under construction

Still being built. Things may change

Laser Beam

Time limit1sMemory limit1024 MB

Summary
Given mirror angle alpha and beam angle beta, count how many times a laser beam reflects off the two mirrors before it travels off to infinity.
Level

Medium5 of 10

Topics
Geometry, Math
Solved
No attempts yet

Problem

Two infinite flat mirrors are placed at an angle α\alpha to each other. Viewed from the side, they appear as two lines on a plane. A laser beam is fired through a tiny hole in one of the mirrors at an angle β\beta, as shown in the figure below.

Count the number of times the beam reflects off the mirrors before it travels off to infinity. The angle of incidence always equals the angle of reflection. The hole is extremely small, so if the beam happens to hit the hole, it still reflects according to the usual rules.

Input

Two integers α\alpha and β\beta are given. Both are angles in degrees, with 1≤α≤1791 \le \alpha \le 179 and 1≤β≤1791 \le \beta \le 179.

Output

Print one integer, the number of reflections.

Hint

In the first example, the beam reflects as shown below.

Examples3

  1. Example 1

    Input
    30 35
    
    Expected output
    4
    
  2. Example 2

    Input
    90 90
    
    Expected output
    0
    
  3. Example 3

    Input
    30 60
    
    Expected output
    3