#include <bits/stdc++.h>
using namespace std;
int f(int n) {
  int a[6];
  int i = 0;
  while (n != 0) {
    int k = 0;
    for (int j = 0; j < i; j++)
      if (a[j] == n % 10) k++;
    if (k > 0) return 0;
    a[i] = n % 10;
    i++;
    n -= n % 10;
    n /= 10;
  }
  return 1;
}
int main() {
  int y;
  cin >> y;
  int x = y + 1;
  while (f(x) != 1) {
    x++;
  }
  cout << x;
  return 0;
}
