x=[_ for _ in input()] x.sort(reverse=True) if len(set(x))==1: print(-1) exit() for i in range(len(x)-1,-1,-1): if x[i]!=x[-1]: x[i],x[-1]=x[-1],x[i] break if x[0]=="0": print(-1) exit() print("".join(x))