N=list(map(int,list(input()))) for i in range(len(N)): T=N[i:] if max(T)==T[0]:continue S=N[:i] x=max(T) for i in range(len(T))[::-1]: if T[i]==x: y=i break for i in range(len(T)): if T[i]!=x: o=i if y>o:T[y],T[o]=T[o],T[y] print(''.join([str(x) for x in S+T])) exit() else: print(''.join([str(x) for x in N])) exit()