CN Tower

No attempts yetTime limit1sMemory limit128 MB

Problem

Christy C. Coder is traveling to a programming competition. On the way she stops in Toronto to do some sightseeing. The annoying part of traveling is that everyone back home expects her to bring back pictures of everything, and Christy hates taking pictures: it makes her look like such a tourist. Fortunately, she has a plan to make her picture-taking quite painless.

At 553 m tall, the CN Tower is the world's tallest free-standing building. 351 m up the tower is the "360" rotating restaurant, which completes a full 360-degree rotation every 72 minutes. From there Christy can see the whole city and take close-up pictures of every landmark with her fancy 100x optical-zoom camera. Because the restaurant itself rotates, she only needs to stand in one place to take pictures in every direction.

The waiters insist that she order something or leave, and nothing on the menu interests her, so she must act quickly before she gets kicked out. Given the directions to the landmarks Christy wants to photograph, determine the minimum amount of time she must spend in the restaurant for it to rotate enough to bring every landmark into view. Assume Christy always points her camera exactly perpendicular to the window to minimize distortion from the glass; a landmark can therefore be photographed only at the instant the window faces its direction exactly. Several landmarks may occupy the same (angular) position, and such landmarks require only one photograph.

Because the staff only realize she is a tourist once she starts taking pictures, timing begins when she takes her first picture. Christy may therefore move to any position in the restaurant without hassle and begin taking pictures from there.

Input

The first line contains an integer $n$ ($2 \le n \le 1000$), the number of landmarks Christy wants to photograph. Each of the next $n$ lines describes one landmark: the landmark name (a string of uppercase and lowercase letters of length at most 40), a single space, and the compass angle $d$ (in degrees) to that landmark from the CN Tower, where 0 = north, 90 = east, 180 = south, 270 = west. $d$ is a real number with $0 \le d < 360$, given to at most two decimal places (hundredths of a degree).

Output

Print a single integer: the minimum number of seconds Christy must remain in the restaurant. If that time is not an integer number of seconds, round it up to the nearest second (take the ceiling).