from sys import stdin def main(): #入力 readline=stdin.readline X=list(readline().strip()) X.sort(reverse=True) s=set(X) if len(s)>=3: flag=True elif len(s)==2: no_zero=0 for i in range(len(X)): if X[i]!="0": no_zero+=1 elif X[i]=="0": flag=False break if no_zero>=2: flag=True break elif len(s)==1: flag=False if flag==False: print(-1) else: n=0 for i in range(len(X)-1,-1,-1): if i==len(X)-1: n=X[i] else: if X[i]!=n: X[i],X[i+1]=X[i+1],X[i] break print("".join(X)) if __name__=="__main__": main()