import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines X = read().decode().rstrip() X = sorted(X, reverse = True) if X[0] == X[-1]: print(-1) exit() if sum(x > '0' for x in X) == 1: print(-1) exit() for i in range(len(X)-2,-1,-1): if X[i] == X[i+1]: continue X[i], X[i+1] = X[i+1], X[i] break answer = ''.join(X) print(answer)