X=list(map(int,input())) first=sorted(X,reverse=True) second=first[:-2]+[first[-1]]+[first[-2]] if second[0]!=0 and first!=second: print(*second,sep='') else: print(-1)