N = list(raw_input())[::-1] l = len(N) for i in xrange(l): m = max(N[:l-i]) idx = N.index(m) if N[l-1-i] != m: N[idx],N[l-1-i] = N[l-1-i],N[idx] break print "".join(N[::-1])