using System.Collections.Generic; using System.Linq; using System; public class Hello { public static void Main() { var a = Console.ReadLine().Trim().ToArray(); var ans = getAns(a); Console.WriteLine(ans); } public static int getAns (char[] a) { var aL = a.Length; var ans = new List(); ans.Add(int.Parse(new string(a))); for (int i = 0; i < aL; i++) for (int j = i + 1; j < aL; j++) { if (a[i] > a[j]) continue; swap(a, i, j); var t = new string(a); ans.Add(int.Parse(t)); swap(a, i, j); } return ans.Max(); } public static void swap (char[] a, int n , int m) { var w = a[n]; a[n] = a[m]; a[m] = w; } }