x = int(input()) for i in range(1, 70): y = x ^ i if bin(y).count("1") == i: print(y) exit() print(-1)