from collections import Counter x = input() c = Counter(x) if len(c.keys()) == 1: print(-1) exit() if len(c.keys()) == 2 and '0' in c.keys(): print(-1) exit() ans = sorted(x, reverse=True) for i in range(len(ans)-1, -1, -1): if ans[i] != ans[i-1]: ans[i], ans[i-1] = ans[i-1], ans[i] break print(''.join(map(str, ans)))