N = int(input()) num = 1 cnt = 1 loss = 0 # bit数算出関数 def bit_cnt(a: int) -> int: return bin(a).count('1') while num != N: if num + bit_cnt(num) > N: num -= bit_cnt(num) loss += 1 else: num += bit_cnt(num) if loss == 2: cnt = -1 break cnt += 1 print(cnt)