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;
void FuckMyLife() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
int gcd(int a, int b) {
  if (!a || !b) return a + b;
  return gcd(b, a % b);
}
long long CalcArithmeticAn(long long a1, long long n, long long d) {
  return a1 + (n - 1) * d;
}
long long CalcArithmeticSn1(long long a1, long long an, long long n) {
  return (n * (a1 + an)) / 2;
}
long long CalcArithmeticSn2(long long a1, long long n, long long d) {
  return (n * (2 * a1 + (n - 1) * d)) / 2;
}
double CalcGeometricAn(long long a, long long r, long long n) {
  return (a * pow(r, n - 1));
}
double CalcGeometricSn(long long a, long long r, long long n) {
  return (a * (1 - pow(r, n))) / (1 - r);
}
bool isDistincit(int n) {
  int a[10] = {0};
  for (int i = 0; i < 4; i++) {
    int sub = n % 10;
    n /= 10;
    a[sub]++;
  }
  for (int i = 0; i < 10; i++)
    if (a[i] > 1) return 0;
  return 1;
}
int main() {
  FuckMyLife();
  int n;
  cin >> n;
  for (int i = n + 1; i <= 9012; i++) {
    if (isDistincit(i)) {
      cout << i << '\n';
      return 0;
    }
  }
  return 0;
}
