#include <iostream>
using namespace std;
int main () {
int a,y, x1, x2, x3, x4 ;
cin >> a;
do{
x1=a%10; //ïîñëåäíÿÿ öèôðà;
x2=a/10%10; //ïðåäïîñëåäíÿÿ öèôðà;
x3=a/100%10; //âòîðàÿ öèôðà;
x4=a/1000; //ïåðâàÿ öèôðà;
}
while( x1 != x2 && x1 != x3 && x1 != x4 && x2 != x3 && x2 != x4 && x3 != x4 );
a++;
cout << a;
}