Upside Down Clock#1438

Upside Down Clock

1 second
64 megabytes
Easy

Have you ever noticed how, on some digital clocks, the digits look strange or even like different numbers when seen upside down? Imagine you have a digital clock that sometimes accidentally gets flipped upside down, but the display gives no indication that it's inverted. The only clue is whether the time displayed is still a valid time!

One day, Alex was examining his new digital clock. He looked at the display and saw . Later, after sunset, he checked again and saw . Confused for a moment, he realized how the digits might look if the clock were upside down.

The image below shows how each digit transforms when the clock is flipped. '' indicates that flipping a digit does not result in a valid digit.

Let's call a time interesting if, when the clock at this time is flipped upside down, the display still shows a valid time. For example, and are interesting (when flipped, the display shows and respectively), while is not interesting (flipping results in ).

Write a program that takes two moments in time, and , and determines how many interesting times occur from to , inclusive.

Input

The input consists of two lines, and , each in "" format, representing the start and end of a time interval. Here, is hours and is minutes.

Output

Output a single integer—the number of interesting moments within the interval from to , inclusive.

Examples

Example 1

Loading
Loading