def cbit(bits): bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555); bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333); bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f); bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff); return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff); n = int(input()) if(n==1): print(-1); quit(); oc = -1; c = 0 m = 1; while(1): s = cbit(m); m += s; c += s; if (m > n): if (s == cbit(m)): print(-1); break; elif (oc == 10): print(-1); break; oc = oc + 1; m = m - s*2; elif (m == n): print(c); break;