import java.math.*; import java.util.*; import java.io.*; class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); char[] cs = sc.next().toCharArray(); int[] a = new int[cs.length]; int cnt0 = 0; for (int i = 0; i < a.length; ++i) { a[i] = (int) (cs[i] - '0'); if (a[i] == 0) ++cnt0; } Arrays.sort(a); boolean same = true; for (int i = 0; i < a.length; ++i) same &= a[i] == a[0]; if (same || cnt0 == a.length - 1) { System.out.println(-1); return; } int p = 0; while (a[p] == a[p + 1]) ++p; a[p + 1] ^= a[p]; a[p] ^= a[p + 1]; a[p + 1] ^= a[p]; PrintWriter pw = new PrintWriter(System.out); for (int i = a.length - 1; i >= 0; --i) { pw.print(a[i]); } pw.println(); pw.close(); } }