An industrial rotary dial has 2^b discrete positions. To minimize misreads as the dial turns, each position is encoded with a b-bit reflected Gray code, constructed so that moving between any two consecutive positions changes exactly one bit.
The standard reflected Gray code sequence for b bits is built recursively: the 1-bit sequence is [0, 1]; the (k+1)-bit sequence is formed by taking the k-bit sequence, appending its own reverse with the new leading bit set to 1 on the appended half (and 0 on the original half).
Given b and a 0-indexed position k (0 \le k < 2^b), report the decimal value of the Gray code assigned to position k.
Input format
Line 1: two space-separated integers b k.
Output format
A single integer: the decimal value of the b-bit reflected Gray code at position k.
Constraints
- 1 ≤ b ≤ 20
- 0 ≤ k < 2^b