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>).
def min_bacteria_count(x):
    low = 1  # Minimum possible number of bacteria
    high = x  # Maximum possible number of bacteria
    min_bacteria = x  # Initialize the minimum bacteria count to the target x

    while low <= high:
        mid = (low + high) // 2  # Calculate the middle value

        # Check if the current middle value can achieve the desired count
        if mid * (mid + 1) // 2 >= x:
            min_bacteria = mid  # Update the minimum bacteria count
            high = mid - 1  # Adjust the upper bound for the binary search
        else:
            low = mid + 1  # Adjust the lower bound for the binary search

    return min_bacteria

# Read the input value
x = int(input())

# Calculate the minimum number of bacteria needed
min_count = min_bacteria_count(x)

# Print the result
print(min_count)
