x=int(input()) for m in range(63): n=x^m if n.bit_count()==m: print(n) exit() print(-1)