l = list(input()) mx = len(l) - list(reversed(l)).index(max(l)) - 1 if mx != 0: for i in range(len(l)): if mx > i: if int(l[mx]) > int(l[i]): l[mx], l[i] = l[i], l[mx] break else: mx = len(l) - list(reversed(l)).index(max(l[i+1:])) - 1 print(''.join(l))