Time

18:02:19
22 May 2012
Version for print

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?


Specifications

   Input

   The number of stones in the pile N (1N10000).

   Output

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


Problem information

Time Limit: 1 seconds
Memory Limit: 64 MB
Balls for the passed test: 9.09091
Complexity: 27% 222/303
Classes: Game strategies

Example

Example input

7

Example output

3


← Page numbering Problems Clocks →