Hide

Problem E
Steam Column

Languages en is
/problems/gufustrokur/file/statement/en/img-0001.jpg
Image by Patricia Fehrentz

Often there is steam rising from the ground around Krafla. Depending on the wind at any given time the column of steam can be leaning in different directions. Plenty of useful data can be inferred from researching such steam columns.

A research team has now taken two pictures where the steam column is leaning two different ways. By how many degrees has the wind direction changed at a minimum?

The direction of the steam column is given as degrees from north, so north is $0^{\circ }$, west is $90^{\circ }$, south is $180^{\circ }$ and east is $270^{\circ }$. One degree east of north is then $359^{\circ }$.

For example, if the pictures show angles of $170^{\circ }$ and $100^{\circ }$ the answer is $70^{\circ }$, because the steam column can rotate in either direction. If the pictures show angles of $355^{\circ }$ and $7^{\circ }$ the answer is $12^{\circ }$ because $359^{\circ }$ and $0^{\circ }$ are adjacent.

Input

The input consists of two lines. The first line contains the direction of the steam column on the first picture, given as an integer from $0$ to $359$. The second line contains the direction of the steam column on the second picture, given as an integer from $0$ to $359$.

Output

Print the minimum possible number of degrees the steam column has rotated between taking the pictures.

Scoring

Group

Points

Constraints

1

100

No further constraints.

Sample Input 1 Sample Output 1
170
100
70
Sample Input 2 Sample Output 2
355
7
12

Please log in to submit a solution to this problem

Log in