import sys K=[1]*60 for i in range(59): K[i+1]=K[i]<<1 K=set(K) N=int(input()) for i in range(1,N//2+1): if (i not in K) and ((N-i) not in K): print(i) sys.exit() print(-1)