The Game about KILL

Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others)

Problem Description

Teacher HU and his 40 students were trapped by the brigands. To show their power, the head of the brigands want to select one people to kill.

Teacher HU and his 40 students will stand in a circle, and every second person would leave, and the last people in the circle would be killed.

For example, if there are 5 persons in the circle, counting proceeds as 2, 4, 1, 5 and person 3 will be killed.

To make his students alive, teacher HU calculated the position to be the last man standing, and sacrifice himself.

Now we consider a more common condition, if teacher HU has N - 1 students, which place should he stand to be the last person.

Input

There are multiple test cases.
Each test case only contains an integer N. (1 ≤ N ≤ 1,000,000,000)

Output

For each test case, output an integer indicating which place should teacher HU stand.

Sample Input

2
3

Sample Output

1
3

Source

dut200901102

Manager

Information
Solved Number100
Submit Number199
Problem Tags
math
number theory
No tag edit access
温馨提示:AC后可以编辑标签哦. ^-^
Login
LoginCancel