1. You are given an integer N which represents the total number of soldiers standing in a circle having position marked from 1 to N. 2. A cruel king wants to execute them but in a different way. 3. He starts executing soldiers from 1st position and proceeds around the circle in clockwise direction. 4. In each step, every second soldier is executed. 5. The elimination proceeds around the circle (which is becoming smaller and smaller as the executed soldiers are removed), until only the last soldier remains, who is given freedom. 6. You have to find the position of that lucky soldier.
1 <= N <= 10^9
A number N
Check the sample ouput and question video.