PCK is making a digital clock as a free activity for his summer vacation. The clock designed by PCK consists of four numbers: two numbers for hours (00-23) and two numbers for minutes (00-59), as shown in the figure below (the figure shows 3:59 a.m.).
Each number consists of seven line segments, which are turned on and off to display the number. Each number is displayed in the format shown below.
The digital clock created by PCK consumes 1 power for each segment only when it changes from off to on, but not the other way around. For example, when changing from number 4 to number 5, two segments are newly lit, so the power consumption is 2. Also, for example, when the time changes from 09:59 to 10:00, it consumes 0, 1, 2, and 1 from the left numbers, for a total of 4.
Two times on the same day $h_1$:$m_1$ and $h_2$:$m_2$ are given. Create a program to find the total amount of electricity consumed while time passes from $h_1$:$m_1$ to $h_2$:$m_2$. However, it is assumed that 0 is displayed in the tens place even when the hour or minute is a one-digit number.
Input is given in the following format.
$h_1$ $m_1$ $h_2$ $m_2$
In the first line, two integers $h_1$ and $m_1$ representing time $h_1$:$m_1$ are given, and in the second line, two integers $h_2$ and $m_2$ representing time $h_2$:$m_2$ are given. In the second line, two integers $h_2$ and $m_2$ representing time $h_2$:$m_2$ are given. However, $0 \leq h_i < 24$, $0 \leq m_i < 60$, $h_1 \times 60 + m_1 < h_2 \times 60 + m_2$.
Output the total power consumption on a single line.
9 59 10 1
4
First, it changes from time 09:59 to time 10:00, then from time 10:00 to time 10:01, so the total power consumption is 4.