def I(): return int(input()) def MI(): return map(int, input().split()) def LI(): return list(map(int, input().split())) S=list(input()) N=len(S) # 1種類だとダメ S2=set(S) if len(S2)==1: print(-1) exit() # 最上位以外全部0だとダメ cnt=S.count("0") if cnt==N-1: print(-1) exit() # print(cnt) S.sort(reverse=True) for i in range(N-1,0,-1): if S[i]!=S[i-1]: S[i],S[i-1]=S[i-1],S[i] break print(''.join(map(str, S)))