B. Simplified Calendar System
time limit per test
5 seconds
memory limit per test
1024 megabytes
input
standard input
output
standard output

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.

Input

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).

Output

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

Examples
Input
20 11 2021 7
29 11 2021
Output
2
Input
20 10 1999 5
15 4 2002
Output
4