from collections import Counter x = list(input().strip()) c = Counter(x) if len(c.keys()) == 1: print(-1) elif c['0'] == len(x) - 1: print(-1) else: v = sorted(c.keys())[0] c[v] -= 1 e = sorted(c.keys(), reverse=True) for i in range(len(e)): t = str(e[i]) if i != len(e) - 2: print(t * c[t], end='') else: print(t * (c[t] - 1), end='') print(v, end='') print(t, end='') print()