n = int(input()) # Write a function that convert the input number # from decimal to binary. def dec_to_bin(num): # First, if the input number is 0, return 0 if num == 0: return str(0) """Understand the core idea of decimal to binary conversion: Repeatedly perform floor division on the input decimal number until the quotient reaches 0, while adding the remainder (0 or 1) to each digit from right to left. """ # Hence, the next step is write a WHILE loop that terminates # once the resultant quotient of the repeated floor division # reaches zero. num_bin = '' while num > 0: num_bin = str(num%2) + num_bin # Add the remainder of the division 2 num = num // 2 # Repeat floor division by 2 return num_bin # Note: the output is a string!! bin_output = dec_to_bin(n) one_count = 0 for char in bin_output: if char == '1': # Each char is a string!! one_count += 1 print(one_count)