n = list(map(int, input())) now_max_i = len(n) - 1 max_num = max(n, key=lambda x: int(x)) flag = False i = 0 while n[i] == max_num: i += 1 if i == len(n): print("".join(map(str, n))) exit() swap_index = i for i in range(len(n)-2,-1,-1): if n[now_max_i] < n[i]: now_max_i = i n[now_max_i],n[swap_index] = n[swap_index], n[now_max_i] print("".join(map(str, n)))