#CCBCHMUOI0000003. Kiểm tra năm và số thứ tự ngày (Day Number in the Year)

Kiểm tra năm và số thứ tự ngày (Day Number in the Year)

Day Number in the Year

Source: Phước Hưng OJ

Version: Phuoc Hung OJ Extended

Problem Statement

Given a valid Gregorian date d/m/y, find its 1-based ordinal day in that year (January 1 is day 1). Add the lengths of all preceding months and d. A leap year has February 29 and occurs if y is divisible by 400, or divisible by 4 but not by 100.

Input

One line contains integers d, m and y in day-month-year order. The date is guaranteed valid.

Output

Print the 1-based ordinal day number.

Subtasks

  • Subtask 1 (20%): y = 2001, m = 1, 1 <= d <= 31.
  • Subtask 2 (30%): y = 2023 and any valid date in that year.
  • Subtask 3 (50%): 1 <= y <= 9999 and a valid Gregorian date.

Examples

Example 1

Input

1 1 2001

Output

1

Explanation

There are no preceding months, so 0+1=1.

Example 2

Input

1 3 2024

Output

61

Explanation

2024 is leap: January has 31 days and February has 29, so March 1 is day 61.

Example 3

Input

31 12 1900

Output

365

Explanation

1900 is not leap, so December 31 is day 365.