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