X = list(input()) X.sort(reverse=True) for i in reversed(range(len(X)-1)): if X[i]!=X[i+1]: X[i],X[i+1]=X[i+1],X[i] if X[0]!='0': print(''.join(X)) exit() print(-1)