X = input() X.sort(reverse=True) X_changed = X[-2:]+X[-1]+X[-2] if X_changed.startswith("0"): print(-1) elif int(X_changed) == int(X): print(-1) else: print(X_changed)