Under construction

Still being built. Things may change

Bored Maru

Interview

Time limit1sMemory limit1024 MB

Summary
Each order covers a circular arc of 2b degrees centered opposite the wall point at angle a. Count the integer sensors hit by at least one arc.
Level

Easy3 of 10

Topics
Intervals, Prefix sum, Implementation
Solved
No attempts yet

Problem

Geunsu is a disciple of the grand wizard Maru. Recently Maru taught Geunsu Blaze, a skill that lets the user face a chosen direction and spread fire through a chosen angle.

Bored Maru wants to test Geunsu's Blaze. Blaze sends fire out endlessly in a specific direction and angle, so Maru tests it inside a special circular training ground. The ground is enclosed by a wall, so when Blaze is used inside, the fire hits the wall and disappears. The wall has sensors that detect Blaze, and they are very sensitive. They detect Blaze even at the boundary where it passes.

Maru orders Geunsu to use Blaze NN times. Each order is as follows.

Maru: Starting from the entrance, move counterclockwise along the wall of the training ground by a∘a^\circ, then cast Blaze toward the center of the training ground across a range of b∘b^\circ.

The figure below shows Maru's order.

In the figure, points O,E,PO, E, P are the center of the training ground, the entrance, and Geunsu's position. \newcommand{arc}\[1]{\stackrel{\Large\frown}{#1}}\arc{LR} is the range of Blaze that hit the wall and disappeared. The solid lines in the figure are the wall. Geunsu always uses Blaze so that ∠EOP=a∘,∠LPR=b∘,∠OPL=∠OPR\angle{EOP}=a^\circ, \angle{LPR}=b^\circ, \angle{OPL}=\angle{OPR} hold.

Geunsu, the top disciple, can always use Blaze exactly. Print the number of sensors that detected Blaze after Geunsu follows all NN orders. There is one sensor at the entrance and 360 sensors in total, one every 1∘1^\circ.

When 1≤b≤1791 \leq b \leq 179, the sensor at Geunsu's position does not detect Blaze. When b=180b = 180, it does.

Input

The first line contains the integer NN, the number of orders Maru gives Geunsu. (1≤N≤1 000 0001 \le N \le 1\,000\,000)

From the second line to line N+1N+1, each line contains the integers aa and bb of the ii-th order, separated by a space. (0≤a≤3590 \le a \le 359; 1≤b≤1801 \le b \le 180)

Output

Print one line containing the number of sensors that detected Blaze after Geunsu follows all NN orders.

Examples1

  1. Example 1

    Input
    2
    10 5
    20 5
    
    Expected output
    21