#yukicoder import copy X = list(input()) X = sorted(X)[::-1] XX = copy.deepcopy(X) XX[-1],XX[-2] = XX[-2],XX[-1] if XX[0] == "0" or X == XX: print(-1) else: print(*XX,sep="")