x = list(map(int, input())) l = len(x) x.sort(reverse=True) for i in range(l - 1, 0, -1): if x[i] != x[i-1]: x[i], x[i-1] = x[i-1], x[i] break else: print(-1) exit() if x[0] == 0: print(-1) else: print(*x, sep="")