x=input() t=sorted(x,reverse=True) for i in reversed(range(len(t))): if t[i] != t[-1]: t[i],t[-1]=t[-1],t[i] xx=''.join(t) if xx[0]=='0': print('-1') elif xx!=x: print(''.join(t)) else: print('-1')