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