Beautiful dates
Vova considers a date written in the format DDMMYYYY to be beautiful if, when reversed, it still represents a valid calendar date. For instance, September 1, 2010 (01092010) is beautiful because reversing it gives February 1, 9010 (01029010), which is a valid date. However, April 3, 1991 (03041991) is not beautiful, as reversing it results in the non-existent 91st month of the year 4030. Vova wants to know how many such beautiful dates exist between his birthdate and the day he started first grade. Help him determine this number.
Input
The first line of the input contains Vova's birthdate in the format DDMMYYYY, and the second line contains the date he started first grade, also in the format DDMMYYYY. Both dates are valid and range from January 1, year one (written as 01010001) to December 31, 9999 (written as 31129999).
Output
Output the total number of beautiful dates.