X = list(input()) X.sort(reverse = True) if X[1] == '0' or X[0] == X[-1]: print(-1) exit() for i in range(len(X)-1,0,-1): if X[i] != X[i-1]: X[i],X[i-1] = X[i-1],X[i] break for i in X: print(i,end="") print()