X = list(str(input())) X = sorted(X, reverse=True) setX = set(X) if len(setX) <= 1 or len(X) - X.count("0") <= 1: print(-1) exit() minX = min(setX) cntMin = X.count(minX) X[-1*cntMin-1],X[-1*cntMin] = X[-1*cntMin],X[-1*cntMin-1] for x in X: print(x,end="")