Game#110

Game

1 second
64 megabytes
Easy

There is a pile with stones. Two players take turns. On each turn, a player must split the pile into two parts of unequal sizes and take all the stones from the smaller part. A player who cannot make a move loses the game.

If you go first and want to guarantee a win, how many stones should you take on your first turn? If there is no winning move, output 0.

Input

The number of stones in the pile (1 \le N \le 10000).

Output

Output the number of stones you should take on your first turn to guarantee a win, or 0 if there is no winning move.

Examples

Example 1

Loading
Loading