import itertools import copy n = int(input()) n_list = [str(e) for e in list(str(n))] comb_list = list(itertools.combinations(list(range(0, len(n_list))), 2)) res = n for i in range(len(comb_list)): copy_list = copy.copy(n_list) front, back = comb_list[i] copy_list[front], copy_list[back] = copy_list[back], copy_list[front] res = max(res, int(''.join(copy_list))) print(res)