import itertools n = input() nls = list(map(int, list(n))) l = len(nls) ls = [int(n)] for i in itertools.permutations([i for i in range(l)],2): tmp = nls.copy() tmp[i[0]], tmp[i[1]] = tmp[i[1]], tmp[i[0]] ls.append(int("".join([str(i) for i in tmp]))) print(max(ls))