Problem D: Friday the 13th
Problem
The "Ritsumeikan University Programming Camp" is held again this year. I'm looking forward to this camp, which is held every year. However, I couldn't resist my desires and spent a lot of money before the camp, so I ran out of money. Therefore, I decided to use the cheapest "Seishun 18 ticket" to travel to Minami-Kusatsu, the nearest station to Ritsumeikan University. This ticket is cheap, but requires many transfers and takes a whole day to travel, so it is very tiring. I realized that the day I was going to travel was Friday the 13th after leaving Aizuwakamatsu Station. I was forced to ride the train for 12 hours while feeling anxious.
Today is the second day of the camp, March 15, 2015, Sunday. Although nothing special happened on the 13th, and I arrived at Minami-Kusatsu, I didn't want to experience such anxiety again. Therefore, as the judge of the second day of the camp, I decided to give a problem that asks for the number of Friday the 13ths that exist within a specified period and have the participants write a program to solve it.
The definition of a leap year is as follows.
A year that is divisible by 4 is a leap year.
However, a year that is divisible by 100 is not a leap year.
However, a year that is divisible by 400 is a leap year.
Input
Six integers Y1, M1, D1, Y2, M2, D2 separated by a space are given in one line.
Constraints
The input satisfies the following constraints.
1 ≤ Y1 ≤ Y2 ≤ 1018
1 ≤ Mi ≤ 12
1 ≤ Di ≤ 31 (Mi = 1, 3, 5, 7, 8, 10, 12)
1 ≤ Di ≤ 30 (Mi = 4, 6, 9, 11)
1 ≤ Di ≤ 28 (Mi = 2 and Yi is not a leap year)
1 ≤ Di ≤ 29 (Mi = 2 and Yi is a leap year)
Y1, M1, D1 is a date that is at least 0 days before Y2, M2, D2
Output
Output the number of Friday the 13ths that exist between Y1, M1, D1 and Y2, M2, D2 on one line.
Sample Input1
2015 3 13 2015 3 13
Sample Output1
1
Sample Input2
2015 2 14 2015 3 15
Sample Output2
1
Sample Input3
1234 5 6 789012345678901234 5 6
Sample Output3
1357101234567708000
