408231: GYM103059 L Tennis Cup
Description
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.
InputThe first line of the input contains $$$n$$$ ($$$1 \le n \le 10^8$$$), the number of participants, including Lang.
OutputOutput 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.
ExamplesInput9Output
1Input
16Output
4Input
11Output
2Input
12Output
2