X = list(input()) X.sort(reverse = True) if X.count("0") == len(X) - 1 or X.count(X[0]) == len(X): print(-1) exit() i = len(X) - 1 while X[i] == X[i - 1]: i -= 1 X[i], X[i - 1] = X[i - 1], X[i] print("".join(X))