X = int(input()) if X==0: print(0) exit() for i in range(100): if (X>>i)&1: msb = i for M in range(msb+10): N = 0 for i in range(100): if ((X>>i)&1)^((M>>i)&1): N += 1<>i)&1: M2 += 1 if M==M2: print(N) exit() print(-1)