#include<bits/stdc++.h>
using namespace std;
int main(){
int y;
cin>>y;
while(true){
y++;
int x=0;
string a= to_string(y);
for(int i=0;i<a.length()-1;i++){
for(int j=i+1; j<a.length(); j++){
if(a[i]==a[j]){
x++;
}
}
}
if(x==0){
cout<<y<<endl;
break;
}
}
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKaW50IG1haW4oKXsKICAgIGludCB5OwogICAgY2luPj55OwogICAgd2hpbGUodHJ1ZSl7CiAgICAgICAgeSsrOwogICAgICAgIGludCB4PTA7CiAgICAgICAgc3RyaW5nIGE9IHRvX3N0cmluZyh5KTsKICAgICAgICBmb3IoaW50IGk9MDtpPGEubGVuZ3RoKCktMTtpKyspewogICAgICAgICAgICBmb3IoaW50IGo9aSsxOyBqPGEubGVuZ3RoKCk7IGorKyl7CiAgICAgICAgICAgICAgICBpZihhW2ldPT1hW2pdKXsKICAgICAgICAgICAgICAgICAgICB4Kys7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgaWYoeD09MCl7CiAgICAgICAgICAgIGNvdXQ8PHk8PGVuZGw7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgIH0KcmV0dXJuIDA7Cn0K