You are a lover of bacteria. You want to raise some bacteria in a box. 

Initially, the box is empty. Each morning, you can put any number of bacteria into the box. And each night, every bacterium in the box will split into two bacteria. You hope to see exactly *x* bacteria in the box at some moment. 

What is the minimum number of bacteria you need to put into the box across those days?
The only line containing one integer *x* (1 ≤ *x* ≤ 10<sup class="upper-index">9</sup>).
import math

def is_in_base_two(n: int):
    if n == 1:
        return False
    p = 2
    if n == p:
        return True
    while True:
        p *= 2
        if p > n:
            return False

        if p == n:
            return True

def find_nearest_power_of_two(n: int):
    power = 2
    last_power = 2
    while n > power:
        last_power = power
        power *= 2
        # print(f"current power {power}")
        # print(f"current last_power {last_power}")
        if power > n:
            return int(math.log(last_power, 2))
        if power == n:
            return int(math.log(power, 2))
    return 1

def find_needed_bact(n:int):
    a = n
    i = 0
    while True:
        i += 1
        if a == 1: break
        if is_in_base_two(a): break
        a = a - (find_nearest_power_of_two(a) ** 2)

    print(i)

def solve():
    pass

def main():
    x = int(input())
    find_needed_bact(x)
    # solve()
    # print(find_nearest_power_of_two(12))
    # print(is_in_base_two(68))

if __name__ == "__main__":
    main()

	  				 		 				  				   			   	