~/algor $ cat problems/yonalishlar-orasidagi-burchak
Angle between directions
Medium
1000 ms
64 MB
46%
A compass has eight directions: s (north), sq (north-east), q (east), jq (south-east), j (south), jg (south-west), g (west), sg (north-west); the angle between neighbouring directions is $45^\circ$. Two directions are given. Find the smaller angle between them in degrees (from $0$ to $180$).
Input
One line with two words — the directions.
Output
One integer — the angle in degrees.
Note
Each direction is one of the eight above.
Examples
Input #1
sq j
Output #1
135
Input #2
g sg
Output #2
45