import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Scanner; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; Scanner in = new Scanner(inputStream); PrintWriter out = new PrintWriter(outputStream); Task solver = new Task(); solver.solve(1, in, out); out.close(); } static class Task { public void solve(int testNumber, Scanner in, PrintWriter out) { String s = in.next(); StringBuilder sb = new StringBuilder(); int[] maxIndex = new int[s.length()]; char max = s.charAt(s.length() - 1); int mi = s.length() - 1; for (int i = s.length() - 2; i >= 0; i--) { if (s.charAt(i) > max) { max = s.charAt(i); mi = i; } maxIndex[i] = mi; } for (int i = 0; i < s.length() - 1; i++) { if (maxIndex[i] != i) { out.print(s.substring(0, i)); out.print(s.substring(maxIndex[i], maxIndex[i] + 1)); out.print(s.substring(i + 1, maxIndex[i])); out.print(s.substring(i, i + 1)); out.println(s.substring(maxIndex[i] + 1, s.length())); return; } } out.println(s); } } }