from collections import defaultdict def main(): X = input() if len(set(X)) == 1: print(-1) exit() if ('0' in set(X)) and (len(X) - X.count('0') <= 1): print(-1) exit() d = defaultdict(int) for x in X: d[x] += 1 ans = "" cnt = 0 second = -1 length = len(d) for key in sorted(d.keys(), reverse=True): if cnt == length - 2: ans += key * (d[key] - 1) second = key elif cnt == length - 1: ans += key ans += second ans += key * (d[key] - 1) else: ans += key * d[key] cnt += 1 print(ans) if __name__ == "__main__": main()