#include <bits/stdc++.h>
using namespace std;
int main() {
  int year;
  cin >> year;
  int start = 0;
  if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)) {
    start = 366;
  } else
    start = 365;
  int initial_days = start;
  year++;
  int curr_days = 0;
  if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)) {
    curr_days = 366;
  } else {
    curr_days = 365;
  }
  while (true) {
    if (start % 7 == 0 && curr_days == initial_days) {
      break;
    }
    if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)) {
      start += 366;
    } else {
      start += 365;
    }
    year++;
    if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)) {
      curr_days = 366;
    } else {
      curr_days = 365;
    }
  }
  cout << year;
}

### Prompt

Develop a solution in cpp to the problem described below:

The girl Taylor has a beautiful calendar for the year y. In the calendar all days are given with their days of week: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday.

The calendar is so beautiful that she wants to know what is the next year after y when the calendar will be exactly the same. Help Taylor to find that year.

Note that leap years has 366 days. The year is leap if it is divisible by 400 or it is divisible by 4, but not by 100 (<https://en.wikipedia.org/wiki/Leap_year>).

Input

The only line contains integer y (1000 ≤ y < 100'000) — the year of the calendar.

Output

Print the only integer y' — the next year after y when the calendar will be the same. Note that you should find the first year after y with the same calendar.

Examples

Input

2016


Output

2044


Input

2000


Output

2028


Input

50501


Output

50507

Note

Today is Monday, the 13th of June, 2016.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int year;
  cin >> year;
  int start = 0;
  if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)) {
    start = 366;
  } else
    start = 365;
  int initial_days = start;
  year++;
  int curr_days = 0;
  if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)) {
    curr_days = 366;
  } else {
    curr_days = 365;
  }
  while (true) {
    if (start % 7 == 0 && curr_days == initial_days) {
      break;
    }
    if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)) {
      start += 366;
    } else {
      start += 365;
    }
    year++;
    if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)) {
      curr_days = 366;
    } else {
      curr_days = 365;
    }
  }
  cout << year;
}

```