ans=True x=int(input()) for i in range(70): if bin(x^i).count("1")==i and y>0: ans=False print(x^i) break if ans: print(-1)