The Fool, as his name suggests, does not know the concept of numbers. To communicate with others, the Fool can only count out the number he wanted to convey.
Through experience, he has developed a better way to count. To convey 15 objects, he would first count 3, followed by 5.
These two numbers represent the side lengths when the objects are arranged in a rectangle.
In this example, he counted a total of $3+5=8$ times.
Now, the fool would like to convey the number $N$. Can you help him to find out the minimum times of counting, using his method?
Input
The first line consists of an integer $N$.
Output
Output the answer as an integer.
Constraints
For all testcases: $1 \le N \le 10^9$
Subtask 1 (50%): $N \le 10^6$
Subtask 2 (50%): No other constraints
Sample Test Cases
Input | Output | |
---|---|---|
15 | 8 | |
The minimum amount of counts is 8, by counting 3 and then 5. | ||
17 | 18 | |
There is only one way to convey 17, which is by counting 17 then 1. |
Scoring: Per Subtask
Authored by s17f18
Appeared in 2024 Mini Contest 3