#VECTAR10. Card Game

Card Game

Changu and Mangu have an ordered deck of n cards numbered 1 to n with card 1 at the top and card n at the bottom. They want to play a game. They perform a wierd operation as long as there are at least two cards in the deck: Changu throws away the top card and then Mangu moves the card that is now on the top of the deck to the bottom of the deck. Your task is to find the last remaining card.

Input

Each line of input (except the last) contains a positive number n ≤ 1000000. The last line contains 0 and this line should not be processed. Input will not contain more than 500000 lines.

Output

For each number from input produce one line of output giving the last remaining card.

Example

Sample Input:
2
3
4
0

Sample Output:
2
2
4

Warning: Large I/O data, be careful with certain languages