X = sorted(input()) N = sorted(set(X)) if len(N) == 1 or X[-2] == '0': print(-1) exit(0) I = X.index(N[1]) X[I - 1], X[I] = X[I], X[I - 1] print(*X[::-1], sep='')