#B3636. Minimum Operations to Obtain Exactly n Characters
Minimum Operations to Obtain Exactly n Characters
Minimum Operations to Obtain Exactly n Characters
Doraemon needs to type exactly \( n \) characters on his computer. Initially, the document contains exactly one character. He can perform the following two operations:
- Add one character to the end of the document, increasing the character count from \( x \) to \( x+1 \).
- Copy the entire document and paste it, doubling the number of characters from \( x \) to \( 2x \).
Determine the minimum number of operations required to obtain exactly \( n \) characters.
inputFormat
The input consists of a single integer \( n \) (\( 1 \leq n \leq 10^{9} \)), which represents the exact number of characters Doraemon needs to have in the document.
outputFormat
Output a single integer representing the minimum number of operations needed to obtain exactly \( n \) characters.
sample
1
0