from sys import stdin def main(): input = lambda: stdin.readline()[:-1] X = input() X = sorted(X, reverse=1) for i in range(len(X) - 1, 0, -1): if X[i] != X[i-1]: X[i], X[i-1] = X[i-1], X[i] if X[0] != '0': print(''.join(X)) else: print(-1) break else: print(-1) main()