def change(N): N_li = list(str(N)) for i in range(len(N_li)): N_li[i] = int(N_li[i]) n_max = max(N_li) for j in range(1, len(N_li) + 1): if N_li[-j] == n_max: N_li[-j] = 0 + N_li[0] N_li[0] = n_max break s = '' for k in range(len(N_li)): s += str(N_li[k]) return int(s) def main(): N = int(input()) print(change(N)) if __name__ == '__main__': main()