시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 (추가 시간 없음) 1024 MB17513411075.862%

문제

Consider a simplified calendar system where each year is 12 months and each month is 30 days, i.e., each year is 360 days. This sure makes the math easy, or does it?

Given a date and what day of the week it is, determine what day of the week a second date is. The second date will be after (timewise) the first date.

입력

There are two input lines. The first input line contains four integers:

  • d (1 ≤ d ≤ 30), providing what day of the month the first date is,
  • m (1 ≤ m ≤ 12), providing what month of the year the first date is,
  • y (1000 ≤ y ≤ 2999), providing what year the first date is, and
  • n (1 ≤ n ≤ 7), providing what day of the week the given date is (1 represents Sunday, 2 represents Monday, …, 7 represents Saturday).

The second input line provides the second date; it contains three integers (similar to the first three integers of the first input line). Again, the second date will be later than the first date (timewise).

출력

Print an integer (between 1 and 7, inclusive) indicating what day of the week the second date is.

예제 입력 1

20 11 2021 7
29 11 2021

예제 출력 1

2

예제 입력 2

20 10 1999 5
15 4 2002

예제 출력 2

4