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