X = list(input()) X = sorted(X)[::-1] XX = X XX[-1],XX[-2] = XX[-2],XX[-1] if XX[0] == "0" or X == XX: print(-1) else: print(*XX,sep="")