#P6819. [PA 2012] Binary Dodgeball

[PA 2012] Binary Dodgeball

Description

There are nn boxes. At the beginning, each box contains one piece.

Two players take turns. Each move, a player may choose a piece in box ii and a positive integer pp, and move the piece to the box numbered 2p×i2^p\times i. If the box numbered 2p×i2^p\times i already contains a piece, then both pieces are removed from the box. The player who cannot make a move loses.

Find the kk-th smallest nn such that the second player can win the game.

Input Format

Only one line, containing one positive integer kk.

Output Format

Only one line, containing one positive integer nn.

2
10

Hint

For 100%100\% of the testdata, 1k<1091\le k<10^9.

Translated by ChatGPT 5