eolymp
bolt
Try our new interface for solving problems

Game

There is a pile with \textbf{N} stones and \textbf{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 \textbf{0}, if you lose? \InputFile The number of stones in the pile \textbf{N} (\textbf{1} ≤ \textbf{N} ≤ \textbf{10000}). \OutputFile Number of stones taken by you in the first turn, or \textbf{0} if you can't win the game.
Time limit 1 second
Memory limit 64 MiB
Input example #1
7
Output example #1
3