#include<iostream>
#include<cstring>
using namespace std;
bool b[10]; /// 判断十个数是否出现过
int main()
{
int a,i;
int c[5];
cin>>a;
for(i=a+1; i<9013; i++)
{
// cout<<"i: "<<i<<endl;
int temp=i;
memset(b,true,sizeof(b));
#include<cstring>
using namespace std;
bool b[10]; /// 判断十个数是否出现过
int main()
{
int a,i;
int c[5];
cin>>a;
for(i=a+1; i<9013; i++)
{
// cout<<"i: "<<i<<endl;
int temp=i;
memset(b,true,sizeof(b));
for(int j=0; j<4; j++)
{
c[j]=temp%10;
temp=temp/10; /// 取每一位数
if(b[c[j]]==true)
b[c[j]]=false;//cout<<b[c[j]]<<endl;} /// 判断是否重复
else
break;
if(j==3) /// 挑够四个不同的数
{
cout<<i<<endl;
return 0;
}
}
{
c[j]=temp%10;
temp=temp/10; /// 取每一位数
if(b[c[j]]==true)
b[c[j]]=false;//cout<<b[c[j]]<<endl;} /// 判断是否重复
else
break;
if(j==3) /// 挑够四个不同的数
{
cout<<i<<endl;
return 0;
}
}
}
}