408231: GYM103059 L Tennis Cup

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

L. Tennis Cuptime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

Back before the pandemic, Lang was an avid tennis player. In fact, he was so naturally talented at the game that when he exerts $$$100\%$$$ of his capabilities, he is guaranteed that he will win any tennis match he played.

In fact, this was demonstrated in a tennis cup that he attended back a couple of years back. In this single-elimination tournament, Lang was able to win the tournament without so much as dropping a single set. When setting up a tournament, the tournament organizers had two goals. The first of which was to minimize the total number of rounds. Specifically, a round in a single-elimination bracket is where everyone that does not have a bye plays an opponent. The tournament organizers want to set it up so that once a participant plays a match, they cannot have any more byes later on in the tournament. Note however, that a participant can have multiple byes before they play a match.

Now, the tournament organizers know that Lang will inevitably win the tournament in such a convincing fashion that they actually want to limit the number of matches that Lang has to play. In fact, they want to maximize the number of byes that Lang will have. Given that they still want to limit the tournament to as few total rounds as possible, determine the minimum matches that the tournament organizers could have made Lang play and have everyone else eliminated with $$$n$$$ participants.

Here is an example with 12 participants, where Lang is able to play only two matches and win, while the total number rounds is limited to 4 and everyone else is eliminated.

Input

The first line of the input contains $$$n$$$ ($$$1 \le n \le 10^8$$$), the number of participants, including Lang.

Output

Output a single integer, the number of matches that Lang needs to play to be crowned victor, given that the number of rounds in the single elimination tournament are limited to the minimum number.

ExamplesInput
9
Output
1
Input
16
Output
4
Input
11
Output
2
Input
12
Output
2

加入题单

上一题 下一题 算法标签: