import java.util.*; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); char[] arr = sc.next().toCharArray(); Arrays.sort(arr); if (arr[0] == arr[arr.length - 1]) { System.out.println(-1); return; } for (int i = 1; i < arr.length; i++) { if (arr[i] != arr[0]) { char x = arr[i]; arr[i] = arr[i - 1]; arr[i - 1] = x; break; } } if (arr[arr.length - 1] == '0') { System.out.println(-1); return; } StringBuilder sb = new StringBuilder(new String(arr)); sb.reverse(); System.out.println(sb); } }