Tennis Championship

A certain tennis championship with P players has a particular set of rules:

  1. Before every round, players are paired randomly.
  2. Each pair so defined establishes a match that will be played.
  3. The winner of a match advances to the next round in the tournament and the loser is eliminated from competition.
  4. If the number of players before a round is odd, then one player (chosen at random) is automatically promoted to the next round. This process should be repeated over and over again until there is exactly one player left. Such a player will be the champion. The Tennis Championship Organization wants to calculate the total number of matches needed to determine the champion. Input The input consists of several test cases, each one consisting of a single line containing a positive integer P, the number of players. Output For each test case, output a line with one integer indicating the number of matches needed to determine the champion. Sample Input 3 2 Sample Output 2 1