x = list(input()) l = len(x) x.sort() num = x[0] idx = -1 for i in range(1, l): if num == x[i]: pass else: idx = i break if idx == -1: print(-1) exit() if l == 2 and x[0] == '0': print(-1) exit() #print(x) x[idx-1], x[idx] = x[idx], x[idx-1] ans = '' while l > 0: ans += x.pop() l -= 1 if ans[0] == '0': print(-1) else: print(ans)