The optimal relocation of a tower of n disks between spires takes exactly 2^n - 1 single-disk moves, generated by the standard recursive routine: relocate the top n-1 disks, move the largest disk once, then relocate the top n-1 disks again. Number the disks 1 (smallest) through n (largest).
Given n and a move index m, report which disk is moved on the m-th move (moves are 1-indexed). The intended approach uses the recursive structure: the (2^(n-1))-th move is the one that shifts disk n, and moves before or after it fall inside the two smaller sub-relocations.
Input format
A single line with two integers: n m.
Output format
A single integer: the number (1..n) of the disk moved on move m.
Constraints
- 1 <= n <= 60
- 1 <= m <= 2^n - 1