Reverse order#5902

Reverse order

0.5 seconds
64 megabytes
Very easy

Consider a recursive function defined on an array consisting of n=2^k elements: a_0, a_1, \dots, a_{n-1}. Divide the array into two arrays: \textbf{A}_1, which consists of 2^{k-1} elements a_0, a_2, \dots, a_{n-2}, and \textbf{A}_2, which consists of 2^{k-1} elements a_1, a_3, \dots, a_{n-1}. Then, run the recursive function first on array \textbf{A}_1, and then on array \textbf{A}_2. Repeat this process until an array with a single element is obtained. At this point, write down this element on a sheet of paper.

Your task is to determine which number will be written as the -th number on the sheet. Initially, array consists of the elements 0, 1, 2, \dots, n-1.

Input

The input consists of a single line with two integers and (1 \leq k \leq 40, 1 \leq m \leq 2^k). Note that n = 2^k.

Output

Output the integer that will be written as the -th number.

Examples

Example 1

Loading
Loading