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