using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static long[] NList => ReadLine().Split().Select(long.Parse).ToArray(); public static void Main() { Solve(); } static void Solve() { var x = ReadLine().ToList(); var zeros = 0; foreach (var xi in x) if (xi == '0') ++zeros; if (zeros + 1 == x.Count) { WriteLine(-1); } else { x.Sort((l, r) => r.CompareTo(l)); if (x[0] == x[^1]) { WriteLine(-1); return; } for (var i = x.Count - 2; i >= 0; --i) { if (x[i] != x[i + 1]) { (x[i], x[i + 1]) = (x[i + 1], x[i]); break; } } WriteLine(string.Concat(x)); } } }