X=sorted([int(s) for s in list(input())]) X_set=sorted(list(set(X))) if len(X_set)==1 or (len(X_set)==2 and X_set[0]==0 and X.count(X_set[1])==1): print(-1) else: for i in range(1,len(X)): if X[i]!=X[i-1]: a=0 a+=X[i] b=0 b+=X[i-1] X[i]=b X[i-1]=a break ans="" for i in range(len(X)): ans+=str(X[len(X)-i-1]) print(ans)