A = list(input()) if len(set(A)) == 1 or len([a for a in A if a != "0"]) == 1: print(-1) else: A.sort() for i in range(len(A) - 1): if A[i] != A[i + 1]: A[i], A[i + 1] = A[i + 1], A[i] print("".join(A)[::-1]) break else: print(-1)