#!/usr/bin/env python3 #fileencoding: utf-8 N = list(input()) ma = -1 for i in range(len(N)-1): for j in range(i,len(N)): N[i],N[j] = N[j], N[i] tmp = int("".join(N)) if tmp > ma: ma = tmp N[i],N[j] = N[j], N[i] print(ma)