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