X = int(input()) if X % 10 == 0 or len(set(X)) == 1: print(-1) else: X = list(X) X.sort() p = X[0] n = len(X) for i in range(1, n): if p != X[i]: tmp = X[i] X[i] = p X[0] = tmp print(''.join(X[::-1]))