Олимпиадный тренинг

Задача 32947. Watch


An electronic ink wristwatch can display the current time in several different forms. One of the forms is an imitation of a mechanical watch with arrows. The watch dial is divided into 12 large hour divisions, and each of them - into 5 small divisions. The angle between the small divisions on the dial is 6. To save energy, the image is redrawn once a minute when you need to move the minute hand. The hour hand also moves discretely, moving every 12 minutes by one small division. Thus at 12:35 the hour hand will point to the 2nd small division to the right of 12 o'clock, and the minute hand will point to 7 o'clock. The angle between the arrows at this moment is 162°. At 12:36 the hour hand will move to the 3rd small division after 12 o'clock and the minute — to the next minor division after 7 o'clock. The angle between the hands of the clock will not change.

Write a program that calculates the value of the "internal" the (smaller) angle between the hour hand and the minute hand at a given time.
The first line of input contains two integers separated by a single space — clock time, hours H and minutes M (\(1 <= H <= 12, 0 <= M <= 59\)).< /div>
Print a single integer between 0 and 180 — the angle between the arrows in degrees.
 
Examples
# Input Output
1 12 35 162