404502: GYM101521 F Anniversaries

Memory Limit:64 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

F. Anniversariestime limit per test1 secondmemory limit per test64 megabytesinputstandard inputoutputstandard output

Today is Day 2048, exactly 2048 days after the programming dual Alice and Bob first met. They fell in love at first sight and have been together since Day 0, the day they first met.

Alice and Bob do everything together — watching films, eating out, and, of course, programming. On special days, they dine out at a high-class restaurant and afterwards work together on an extra tough programming problem.

The special days include:

  • Anniversaries of Day 0, excluding Day 0 itself. For example, if "Day 0" is 13th January 2011, then every 13th day of January starting from 2012 would be a special day.
  • Day 100n, where n is any positive integer. For example, if "Day 0" is 13th January 2011, then 23rd April 2011, 1st August 2011, and so on, would be special days.
  • Alice's birthdays.
  • Bob's birthdays.

Note that if more than one of the special events listed above occur on the same day, the day is still a single special day and you should not count it more than once.

Alice has just asked Bob whether he remembers how many special days there are since day 1. Given the date of Day 0 and the birthdays of Alice and Bob, you are to help Bob answer Alice's question. If Bob fails to answer correctly, Alice is going to get really angry!

Hint: There are 28 days in February in a common year and 29 days in February in a leap year. Year Y is a leap year if and only if Y is a multiple of 400, or Y is a multiple of four and is not a multiple of 100.

Input

The first line of input consists of the date of Day 0, given in the format DD/MM/YYYY. Day 0 is no earlier than 1st January 1950 and is no later than 13th January 2011.

The second line of input consists of the date (month + day) of Alice's birthday. The third line of input consists of the date (month + day) of Bob's birthday. These birthdays are given in the format DD/MM.

Output

Output one single integer, the number of special days between Day 1 and Day 2048 (the current day) inclusive.

ExamplesInput
13/01/2011
23/04
31/12
Output
35
Input
25/01/1999
29/02
25/01
Output
26

加入题单

算法标签: