Time limit
2s
Memory limit
128 MB
Dasom rode a time machine to the year 8364. Fortunately, Earth is peaceful.
Before returning to 2008, Dasom bought a clock. Because Dasom cannot read analog clocks, the clock is digital. A digital clock displays time in the form HH:MM:SS, where the three fields are usually read from left to right as hour, minute, and second.
However, Dasom does not know whether people in 8364 write time in the same order as in 2008. What is written as hour:minute:second in 2008 might be written as minute:hour:second in 8364.
An hour must be from 01 to 12, and a minute or second must be from 00 to 59.
Given the three two-digit numbers shown on Dasom's clock, count how many different ways the display can be read as a valid time. Even if two readings represent the same actual time, they are counted separately when the positions assigned to hour, minute, and second are different. The answer may be 0.
For instance, 21:23:01 can be read with 01 as the hour and 21, 23 as minute and second in either order.
The first line contains the displayed time.
The time is given in the form DD:DD:DD. It is always exactly 8 characters long, including the colons, and each D is a digit from 0 to 9.
Print the number of possible valid readings of the displayed time.