X = sorted(input())[::-1] x = X.count(min(X)) if len(set(X)) == 1 or len(X) - X.count('0') <= 1: print(-1) else: X[-1*x-1], X[-1*x] = X[-1*x], X[-1*x-1] print(''.join(X))