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>
char dummy[5];
int bilprima[] = {
    2,   3,   5,   7,   11,  13,  17,  19,  23,  29,  31,  37,  41,  43,
    47,  53,  59,  61,  67,  71,  73,  79,  83,  89,  97,  101, 103, 107,
    109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181,
    191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263,
    269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349,
    353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433,
    439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521,
    523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613,
    617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701,
    709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809,
    811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887,
    907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997};
using namespace std;
long long sqr(long long x, long long z) { return ((x % z) * (x % z)) % z; }
long long bigpow(long long x, long long y, long long z) {
  if (y == 0)
    return 1;
  else if (y == 1)
    return x % z;
  else if (y % 2 == 0)
    return sqr(bigpow(x, y / 2, z), z);
  else
    return ((x % z) * sqr(bigpow(x, y / 2, z), z)) % z;
}
void outar(int *ar, int st, int sz) {
  for (int i = st; i <= sz; i++) {
    printf("%d", ar[i]);
    if (i != sz) printf(" ");
  }
  printf("\n");
}
void outvec(vector<int> v) {
  int sz = v.size();
  for (int i = 0; i < sz; i++) {
    printf("%d", v[i]);
    if (i != sz - 1) printf(" ");
  }
  printf("\n");
}
string add(string a, string b) {
  string result = "";
  int lena = a.length();
  int lenb = b.length();
  int len = max(lena, lenb);
  reverse(a.begin(), a.end());
  reverse(b.begin(), b.end());
  for (int i = lena; i < len; i++) a = a + "0";
  for (int i = lenb; i < len; i++) b = b + "0";
  int simpan = 0;
  for (int i = 0; i < len; i++) {
    int hasil = ((int)a[i] - 48) + ((int)b[i] - 48) + simpan;
    simpan = hasil / 10;
    hasil %= 10;
    result = result + ((char)(hasil + 48));
  }
  if (simpan > 0) {
    result = result + ((char)(simpan % 10 + 48));
    simpan /= 10;
    if (simpan != 0) result = result + ((char)(simpan + 48));
  }
  reverse(result.begin(), result.end());
  return result;
}
string subt(string a, string b) {
  string res = "";
  reverse(a.begin(), a.end());
  reverse(b.begin(), b.end());
  int lena = a.length();
  int lenb = b.length();
  int len = max(lena, lenb);
  for (int i = lena; i < len; i++) a = a + "0";
  for (int i = lenb; i < len; i++) b = b + "0";
  int aa[105], bb[105], cc[105];
  for (int i = 0; i < len; i++) {
    aa[i] = ((int)(a[i])) - 48;
    bb[i] = ((int)(b[i])) - 48;
  }
  for (int i = 0; i < len; i++) {
    int hasil = aa[i] - bb[i];
    if (hasil < 0) {
      hasil += 10;
      aa[i + 1]--;
    }
    cc[i] = hasil;
  }
  int st = len - 1;
  while (cc[st] == 0) st--;
  for (int i = st; i >= 0; i--) {
    res = res + ((char)(cc[i] + 48));
  }
  return res;
}
int n;
bool use[15];
int main() {
  scanf("%d", &n);
  n++;
  while (1) {
    int t = n;
    bool can = 1;
    memset(use, 0, sizeof use);
    while (t > 0) {
      if (use[t % 10]) can = 0;
      use[t % 10] = 1;
      t /= 10;
    }
    if (can) {
      printf("%d", n);
      break;
    }
    n++;
  }
  printf("\n");
  return 0;
}
