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