n = int(input()) position = 1 counter = 1 while position < n: # binary step p_b = bin(position) p_b_ones = p_b.count('1') # update position position += p_b_ones counter +=1 if n == 1: print(1) elif n == position: print(counter) else: print(-1)