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