import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; public class No39 { public static void main(String[] args) throws IOException{ //桁の数字を入れ替え String str = readStr()[0] , s; String[] N = str.split("") , clone; int max = Integer.parseInt(str); for(int i = 0;i < N.length;i++) { for(int j = i + 1;j < N.length;j++) { clone = N.clone(); str = ""; s = clone[j]; clone[j] = clone[i]; clone[i] = s; for(String c : clone) { str += c; } max = Math.max(max, Integer.parseInt(str)); } } System.out.println(max); } public static String[] readStr() throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); ArrayList list = new ArrayList<>(); do { list.add(br.readLine()); }while(br.ready()); br.close(); String[] text = new String[list.size()]; list.toArray(text); return text; } }