#0004BA

O-Metuzalem

Everybody who read good old “Alan Ford”, know that Number 1 lives from time when first primates walk on Earth. Nobody knows exactly which year was when he was born but surely it was 100000 yers before Christ.


Image: metuzalem

Suppose that we know time and when he was born, you need to calculate howmany birthdays Number 1 had between two given moments on human existings.

Formats and constrains:
• All three moments are given in next format:
hour:minute:second, day-month-year, era
• 0 <= hour <= 23
• 0 <= minute <= 59
• 0 <= second <= 59
• 1 <= day <= 31 (will be correct with month and year)
• 1 <= month <= 12
• 1 <= year <= 100000 (will be correct with era)
• era can be either BC (Before Christ) or AC (After Christ)

SOME NOTICES.
• Year zero not egzist.
• Number one surely was not born on leap day (this was not alowed by tribe magicions).
• Number one celebrate his birthday exactly on time (in second).


InputIn firs line of standard input is time and date of his birth, but not year and era
In second and third row are two given time moments (in above format), not necesserely hronologycal: T1 and T2.

OutputIn one and only row of output You need to write howmany birthdays are celebrated by Number one, between moments T1 i T2, inclucevly.

Example 1

Input:
8:0:0, 22-12
0:0:0, 1-1-1900, AC
23:59:59, 30-11-2011, AC

Output:
111



Example 2

Input:
8:0:53, 13-12
23:59:59, 31-12-1900, BC
0:0:0, 30-11-2011, BC

Output:
112



Example 3

Input:
11:11:11, 11-11
11:11:11, 11-11-1, AC
11:11:11, 11-11-1, BC

Output:
2

Submit solution

Coming later

The grading service will be connected in a later migration step. You can inspect the task and your previous results now.