P27799 [洛谷] Typing Task
普及
题目描述

Problem Description

Doraemon is typing on a computer. He needs to type a total of $n$ characters, but currently, there is only one character in the document.

Doraemon has two operations he can perform. Assuming there are currently $x$ characters in the document, he can choose to:

  • Add one character to the end of the document. The number of characters becomes $x+1$.
  • Duplicate the entire document by copying and pasting it. The number of characters becomes $2x$.

Determine the minimum number of operations required for Doraemon to have exactly $n$ characters.

Input Format

A single line containing a positive integer $n$.

Output Format

A single line containing a positive integer, representing the minimum number of operations.

Sample Input and Output

Sample Input #1

16

Sample Output #1

4

Sample Input #2

5

Sample Output #2

3

Notes

Sample Explanation

For Sample Data 1, the sequence is $1 \to 2 \to 4 \to 8 \to 16$, totaling 4 steps.

For Sample Data 2, the sequence is $1 \to 2 \to 4 \to 5$, totaling 3 steps.

Data Size and Constraints

For $100\%$ of the data, $n \leq 10^6$.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
16
样例输出
4