Flavius Josephus and 40 of his fellow rebels were trapped and surrounded by the Romans. His companions preferred suicide to surrender, so they decided to stand in a circle and, going around it, kill every third person until no one was left. Josephus did not want to die, so he calculated in advance the position that would be the last one standing (and, since no one was left to watch, he did not kill himself).
Here we consider a variant of this game in which every second person leaves the circle. Because we now have computers, there can be far more than 41 participants. Compute the safe position. Be careful: we might run your program to determine the winner of this contest!
The input consists of several test cases. Each case gives the number of participants $n$. To make things harder, $n$ is always given in the format xyez, with the following meaning: when $n$ is written in decimal, its first digit is $x$, its second digit is $y$, and then follow $z$ zeros. That is, $n = (10x + y)\cdot 10^z$. Here $0 \le x, y \le 9$ and the number of zeros satisfies $0 \le z \le 6$. It is guaranteed that $n > 0$. The last test case is followed by the string 00e0.
For each test case, print on its own line the position of the person who survives. The participants are numbered from $1$ to $n$, and counting starts at person 1, so the first person to leave is number 2. For example, if there are 5 people in the circle, the counting proceeds as $2, 4, 1, 5$ and person 3 stays alive.