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