# -*- coding: utf-8 -*- """ No.39 桁の数字を入れ替え https://yukicoder.me/problems/no/39 """ import sys from sys import stdin input = stdin.readline def find_nums(numbers, target): res = [] for i, n in enumerate(numbers): if n == target: res.append(i) return res def main(args): N = list(input().strip()) largest = sorted(N, reverse=True) t1, t2 = 0, 0 for n, l in zip(N, largest): if n != l: t1 = l t2 = n break if t1 != 0: p1 = find_nums(N, t1) p2 = find_nums(N, t2) N[p1[-1]], N[p2[0]] = N[p2[0]],N[p1[-1]] print(*N, sep='') if __name__ == '__main__': main(sys.argv[1:])