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 = 1;i < N.length;i++) { clone = N.clone(); s = clone[i]; clone[i] = clone[0]; clone[0] = s; str = ""; 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; } }