import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.HashSet; import java.util.Scanner; import java.util.Set; import java.util.Collections; /** * 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(); for (int i = 0; i < s.length() - 1; i++) { Set cs = new HashSet<>(); for (int j = i + 1; j < s.length(); j++) cs.add(s.charAt(j)); char tc = Collections.max(cs); char ic = s.charAt(i); if (tc > ic) { int index = s.lastIndexOf(tc); sb.append(s.substring(0, i)); sb.append(tc); sb.append(s.substring(i + 1, index)); sb.append(ic); sb.append(s.substring(index + 1, s.length())); out.println(sb); return; } } out.println(s); } } }