#include int main(void) { unsigned short n, s = 1, t = 0, i = 1, j, a, b; scanf("%hd", &n); for(; !(s == n); i++){ t = 0; for(j = 0; j < 16; j++) if(s & (1 << j)) t++; if(s + t <= n) s += t; else if(s + t > n){ s -= t; a = t; if(a == b){ i = -1; break; } b = t; } } printf("%hd\n", i); return 0; }