def pop_count(n): return bin(n).count("1") X = int(input()) for i in range(1, 64): b = X ^ i if i == pop_count(b): print(b) exit() print(-1)