N=int(input()) ANS=N S=list(str(N)) for i in range(len(S)): for j in range(len(S)): S[i],S[j]=S[j],S[i] x="".join(S) ANS=max(ANS,int(x)) S[i],S[j]=S[j],S[i] print(ANS)