#include<bits/stdc++.h>
using namespace std;
set<int>s;
bool is(int x){
s.clear();
for(int i=0;i<4;i++){
int b = x%10;
//cout<<b<<" ";
s.insert(b);
x=x/10;
}
//cout<<s.size()<<"\n";
if(s.size()==4) return true;
return false;
}
int main(){
int b;
cin>>b;
for(int i=b+1;i<=9000;i++){
if(is(i)){
cout<<i;
//cout<<"here\n";
break;
}
}
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCnNldDxpbnQ+czsKCmJvb2wgaXMoaW50IHgpewoKICAgIHMuY2xlYXIoKTsKCiAgICBmb3IoaW50IGk9MDtpPDQ7aSsrKXsKICAgICAgICBpbnQgYiA9IHglMTA7CiAgICAgICAgLy9jb3V0PDxiPDwiICI7CiAgICAgICAgcy5pbnNlcnQoYik7CiAgICAgICAgeD14LzEwOwogICAgfQoKICAgIC8vY291dDw8cy5zaXplKCk8PCJcbiI7CgogICAgaWYocy5zaXplKCk9PTQpIHJldHVybiB0cnVlOwogICAgcmV0dXJuIGZhbHNlOwoKfQoKaW50IG1haW4oKXsKCgoKICAgIGludCBiOwogICAgY2luPj5iOwoKICAgIGZvcihpbnQgaT1iKzE7aTw9OTAwMDtpKyspewogICAgICAgIGlmKGlzKGkpKXsKICAgICAgICAgICAgY291dDw8aTsKICAgICAgICAgICAgLy9jb3V0PDwiaGVyZVxuIjsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgfQoKCiAgICByZXR1cm4gMDsKCn0=