n=int(input())
l=[int(i) for i in str(n)]
length=len(l)
pt=0
for i in range(length-1,0,-1):
if(l[i-1]<l[i]):
pt=i-1
break
if(pt==0):
l.sort()
res=''.join([str(i) for i in l])
print(res)
else:
for i in range(length-1,pt,-1):
if(l[i]>l[pt]):
l[i],l[pt]=l[pt],l[i]
break
ans=l[:pt+1]+l[pt+1:][::-1]
res=''.join([str(i) for i in ans])
print(res)
To embed this program on your website, copy the following code and paste it into your website's HTML: