import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Scanner; import java.util.TreeMap; public class Main { @SuppressWarnings("resource") public static void main(String args[]) { Scanner scanner = new Scanner(System.in); int n=scanner.nextInt(); Mapmap=new TreeMap<>(); int key=1; int tmpKey=0; int tmpVal=0; for(int i=n;i>0;i/=10) { tmpKey=key; tmpVal=i%10; map.put(key, i%10); key++; } List> entryList = new ArrayList>(map.entrySet()); Collections.sort(entryList, new Comparator>() { public int compare(Entry obj1, Entry obj2) { return obj2.getValue().compareTo(obj1.getValue()); } }); int tmpKey1=entryList.get(0).getKey(); int tmpVal1=entryList.get(0).getValue(); map.put(tmpKey1, tmpVal); map.put(tmpKey, tmpVal1); String ans=""; for(int v:map.values()) { ans=v+ans; } System.out.println(Integer.parseInt(ans)); } }