Vertical Calendar
Time limit1sMemory limit512 MB
- Level
Not classified yet
- Solved
- No attempts yet
Problem
Seonghyeon looked closely at a calendar and noticed that some of its columns have 5 cells.
Seonghyeon calls a calendar column with 5 cells a "vertical calendar".

Seonghyeon wants to know how many "vertical calendars" are in the calendar of year .
Help Seonghyeon by finding the number of "vertical calendars" in the calendar of year .
Input
The first line contains .
The second line contains the day of the week of January 1 of year . Days are given as numbers from 1 to 7, which stand for [Sun, Mon, Tue, Wed, Thu, Fri, Sat] in order. The input may differ from the real calendar.
Output
Print the number of "vertical calendars" in the calendar of year .
Hint
Account for leap years when calculating.
A year is a leap year if it is a multiple of 4 and not a multiple of 100, or if it is a multiple of 400.
2024 is a multiple of 4 and not a multiple of 100, so it is a leap year.
2100 is a multiple of both 4 and 100. It is not a multiple of 400, so it is not a leap year.
2400 is a multiple of 400, so it is a leap year.
In a common year, February ends on the 28th. In a leap year, it ends on the 29th. So a common year has 365 days and a leap year has 366 days.