X=str(input()) x=[] y=[] cnt=0 for i in range(len(X)): x.append(X[i]) x.sort(reverse=True) for i in range(len(x)-2,0,-1): if x[i]!=x[i+1] and x[0]!="0": x[i],x[i+1]=x[i+1],x[i] print("".join(x)) cnt+=1 break if cnt == 0: print(-1)