import java.util.*; public class Main { private static Scanner sc = new Scanner(System.in); public static void main(String[] args) throws Exception { String s = sc.next(); int len = s.length(); int max = Integer.valueOf(s); for (int i = 0;i < len;i++) { for (int j = i+1;j < len;j++) { max = Math.max(max, num(s,i,j)); } } System.out.println(max); } private static int num(String s, int i, int j) { char[] ary = s.toCharArray(); char tmp = ary[i]; ary[i] = ary[j]; ary[j] = tmp; return Integer.valueOf(new String(ary)); } }