#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
int a[15],t[15],answer[15];
int e[10];
int itoz(LL x)
{
memset(a,0,sizeof(a));
memset(t,0,sizeof(t));
memset(answer,0,sizeof(answer));
memset(e,0,sizeof(e));
int cur = 0;
while (x != 0)
{
cur++;
t[cur] = x % 10;
if (x % 10 == 0) return -1;
x /= 10;
}
for (int i = cur;i >= 1;i--) a[cur-i+1] = t[i];
for (int i = 1;i <= cur;i++) e[a[i]]++;
for (int i = 0;i <= 9;i++) if (e[i] > 1) return -1;
return cur;
}
bool isxun(LL size)
{
for (int i = 1;i <= size;i++)
{
int j = 1,w = 0;
while (j <= a[i])
{
j++;
w++;
w = (w - 1) % size + 1;
}
answer[i] = w;
}
for (int i = 1;i <= size;i++) if (a[i] != answer[i]) return false;
return true;
}
int main()
{
LL n;
cin >> n;
while (true)
{
n++;
int s = itoz(n);
if (s == -1 || s > 10) continue;
if (isxun(s))
{
cout << n << endl;
return 0;
}
}
return 0;
}
小猴编程(7518098414547896)