N = [i for i in input()] n = N.copy() n.sort() n.reverse() for i in range(len(N)): if N[i] != n[i]: for j in range(len(N) - 1, i, -1): if N[j] == n[i]: N[i], N[j] = N[j], N[i] break break print(''.join(N))