s = list(input()) n = len(s) if s == [s[0]] * n: print(-1) exit(0) s = sorted(s)[::-1] s[-1],s[-2] = s[-2],s[-1] if s[0] == '0': print(-1) else: print(''.join(s))