X=sorted(input(),reverse=True) if X[0]==X[-1] or X[1]=="0": print(-1) else: for i in reversed(range(1,len(X))): if X[i]!=X[i-1]: X[i],X[i-1]=X[i-1],X[i] print("".join(X));exit()