#include <bits/stdc++.h>
using namespace std;
int distinct(int n) {
  int temp, b[5], k = 0;
  while (n != 0) {
    temp = n % 10;
    b[k++] = temp;
    n /= 10;
  }
  for (int i = 0; i < 4; i++)
    for (int j = i + 1; j < 4; j++)
      if (b[i] == b[j]) return 0;
  return 1;
}
int main() {
  int y;
  cin >> y;
  for (int i = y + 1; i < 9013; i++)
    if (distinct(i) == 1) {
      cout << i;
      break;
    }
  cout << endl;
  return 0;
}
