S = list(input()) n = len(S) F = [-1 for _ in range(10)] L = [-1 for _ in range(10)] for i in range(n): num = int(S[i]) if F[num] == -1: F[num] = i for i in range(n - 1, -1, -1): num = int(S[i]) if L[num] == -1: L[num] = i flag = False for i in range(9, 0, -1): if L[i] == -1: continue for j in range(i - 1, -1, -1): if F[j] == -1: continue if L[i] > F[j]: S[L[i]], S[F[j]] = S[F[j]], S[L[i]] flag = True break if flag: break print(''.join(S))