import collections x = list(input()) x = [int(_) for _ in x] c = collections.Counter(x).most_common() c.sort(reverse=True) type = len(c) if type < 2: print(-1) exit() if len(x) == 2 and (x[0] == 0 or x[1] == 0): print(-1) exit() ans = "" for i in range(len(c)): if c[i][1] > 0: ac = str(c[i][0]) * c[i][1] ans += ac for i in range(len(ans)): if ans[len(ans)-1] != ans[len(ans)-1-i]: idx = len(ans)-1-i break #print(ans, idx) print(ans[0:idx] + ans[len(ans)-1] + ans[idx+1:len(ans)-1] + ans[idx])