Vova likes to notice "beautiful" moments on digital clocks (which display time in the format HH:MM, that is, two digits for hours and two digits for minutes, for example, 07:05). Vova considers the clock readings beautiful when at least one of the following conditions is met:
1) The values of hours and minutes are equal, for example: 21:21.
2) The values of hours and minutes look mirrored, meaning the minute value is a permutation of the hour value's digits in reverse order, for example: 21:12.
3) The values of hours and minutes together form four consecutive digits (that is, each subsequent digit on the display is one more than the previous one), for example: 01:23.
Vova is interested in how many beautiful clock readings will appear on the display from the moment the clock shows $$$h_1$$$ hours and $$$m_1$$$ minutes until the moment the clock shows $$$h_2$$$ hours and $$$m_2$$$ minutes (both readings inclusive; if $$$h_1 = h_2$$$ and $$$m_1 = m_2$$$, then only one clock reading is considered).
The input consists of four integers written sequentially: $$$h_1, m_1, h_2, m_2$$$, each number on a separate line ($$$0 \leq h_1, h_2 \leq 23$$$, $$$0 \leq m_1, m_2 \leq 59$$$).
The output should be a single number— the count of beautiful time readings.
Each test is evaluated independently.
2002030
2
17311731
0
| Name |
|---|


