import sys def count_one(num): count = 0 bin_num = list(bin(num)) for i in range(len(bin_num)): if(bin_num[i] == '1'): count += 1 i += 1 return count def main(): N = int(input()) total = 1 move_count = 1 flag = False while(total != N): move = count_one(total) total += move if(total > N): if(flag == True): print(-1) sys.exit() total -= move * 2 flag = True move_count += 1 print(move_count) if __name__ == '__main__': main()