It seems like the year of 2013 came only yesterday. Do you know a curious fact? The year of 2013 is the first year after the old 1987 with only distinct digits.

Now you are suggested to solve the following problem: given a year number, find the minimum year number which is strictly larger than the given one and has only distinct digits.

Input

The single line contains integer y (1000 ≤ y ≤ 9000) — the year number.

Output

Print a single integer — the minimum year number that is strictly larger than y and all it's digits are distinct. It is guaranteed that the answer exists.

Examples

Input

1987


Output

2013


Input

2013


Output

2014
#include <bits/stdc++.h>
using namespace std;
long long Factorail(long long n) {
  long long fact = 1;
  if (n == 0 || n == 1)
    return 1;
  else {
    for (int i = 2; i <= n; i++) {
      fact *= i;
    }
  }
  return fact;
}
long long Power(long long n, long long p) {
  long long pow = 1;
  if (n == 0)
    return 1;
  else {
    for (int i = 0; i < p; i++) {
      pow *= n;
    }
  }
  return pow;
}
long long SumOFNum(long long n) {
  long long count = 0;
  long long sum = 0;
  bool f = false;
  while (n >= 1) {
    sum += n % 10;
    n /= 10;
    f = true;
  }
  if (f == true) count++;
  long long sum2 = 0;
  long long c = 0;
  while (sum >= 1) {
    if (sum < 10 && c == 0) break;
    sum2 += sum % 10;
    sum /= 10;
    c++;
    count++;
  }
  return count++;
}
long long BeautifulYear(long long y) {
  string s2 = "";
  set<char> myset;
  myset.clear();
  stringstream ss;
  ss << y;
  s2 = ss.str();
  for (int i = 0; i < s2.length(); i++) {
    myset.insert(s2[i]);
  }
  if (s2.length() == myset.size())
    return y;
  else {
    y += 1;
    return BeautifulYear(y);
  }
}
int main() {
  const long long size = 10001;
  long long m, arr[size], x, count, t, n, k;
  string s1, s2;
  long long d1, m1, y1, d2, m2, y2;
  bool check = false;
  while (cin >> y1) {
    long long result = BeautifulYear(y1 + 1);
    cout << result << endl;
  }
  return 0;
}
