cho.sh
Notes
Loading...

Day of the Year

Time limit

1s

Memory limit

128 MB

Problem

Many everyday tasks, such as counting vacation days, require calculating periods between dates. A simple way is to choose a starting date and count one day at a time until the target date.

In this problem, use January 1 of the same year as the starting point and determine which day number the given date has in that year.

For example, August 13, 2005 is day 225 of that year. August 13, 2004 is day 226, because 2004 is a leap year.

A year is a leap year if it is divisible by 4 but not by 100, except that years divisible by 400 are leap years. Therefore, 2000 and 1976 are leap years, while 1900 and 1977 are not.

February has 28 days in a common year and 29 days in a leap year. April, June, September, and November have 30 days; all other months have 31 days.

For each given date, output its day number within the year.

Input

The input consists of several lines.

Each line contains a day, a month, and a year separated by spaces. The day and month are always valid, and the year is always between 1700 and 2200, inclusive.

The input ends when 0 0 0 is given.

Output

For each input date, output one line containing the date's day number within its year.