x=int(input()) for i in range(1,65): n=x^i if bin(n).count('1')==i: print(n) exit() print(-1)