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;
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {
  return a.second < b.second;
}
bool sortbysecAsc(const pair<int, int> &a, const pair<int, int> &b) {
  return a.second < b.second;
}
bool sortbyfirstAsc(const pair<int, int> &a, const pair<int, int> &b) {
  return a.first < b.first;
}
bool sortbysecDesc(const pair<int, int> &a, const pair<int, int> &b) {
  return a.second > b.second;
}
bool sortbyfirstDesc(const pair<int, int> &a, const pair<int, int> &b) {
  return a.first > b.first;
}
vector<pair<long long, long long> > v;
vector<long long> vv, v1, v2, v3;
vector<char> ch;
vector<string> str;
set<pair<int, int> > s;
int arr[1000000];
int dp[50000];
char a[3003];
vector<pair<int, int> > dv;
using namespace std;
bool isPowerOfTwo(int n) { return (ceil(log2(n)) == floor(log2(n))); }
void SieveOfEratosthenes(int n) {
  bool prime[n + 1];
  memset(prime, true, sizeof(prime));
  for (int p = 2; p * p <= n; p++) {
    if (prime[p] == true) {
      for (int i = p * 2; i <= n; i += p) prime[i] = false;
    }
  }
  int j = 0;
  int prm[50000];
  for (int i = 2; i <= n; i++) {
    if (prime[i]) {
      prm[j] = i;
      j++;
    }
  }
}
int main() {
  int n;
  cin >> n;
  int m = n;
  while (1) {
    m++;
    set<int> s;
    int x = m;
    while (x != 0) {
      s.insert(x % 10);
      x /= 10;
    }
    if (s.size() == 4) {
      cout << m << endl;
      break;
    }
  }
  return 0;
}
