eolymp
Competitions

Оператор розгалуження

Game

There is a pile with N stones and 2 players. They plays by turns. In his turn the player must divide a pile into two unequal parts and take away smaller one. If it is impossible to do it, the player loses.

How many stones would you take if you expect to win the game, when you play as first player, or 0, if you lose?

Input

The number of stones in the pileN (1N10000).

Output

Number of stones taken by you in the first turn, or 0 if you can't win the game.

Time limit 1 second
Memory limit 64 MiB
Input example #1
7
Output example #1
3