using System.Linq; using System; public class Hello { static void Main() { var s = Console.ReadLine().Trim().ToArray(); Console.WriteLine(getAns(s)); } static string getAns(char[] s) { Array.Sort(s); for (int i = 0; i < s.Length - 1; i++) { if (s[i] != s[i + 1]) { var tmp = s[i]; s[i] = s[i + 1]; s[i + 1] = tmp; if (s[s.Length - 1] != '0') { Array.Reverse(s); var ans = new string(s); return ans; } else return "-1"; } } return "-1"; } }