n people stand in a circle, numbered 1 to n. Starting the count at person 1, every k-th person is eliminated, and counting continues around the remaining circle. Find the number of the last remaining person.
Input format
One line: two integers n and k.
Output format
One line: the 1-indexed position of the survivor.
Constraints
- 1 <= n <= 1000000
- 1 <= k <= 1000000