#include int main(void) { unsigned short n, position = 1, i = 1, j; char step, check[16] = {}, count = 0; scanf("%hd", &n); for(; !(position == n); i++){ step = 0; for(j = 0; j < 16; j++) if(position & (1 << j)) step++; if(position + step <= n) position += step; else if(position + step > n){ position -= step; check[count] = step; for(j = 0; j < 16; j++){ if(count == j) continue; if(check[count] == check[j]){ i = -1; goto end; } } count++; } } end:; printf("%hd\n", i); return 0; }