#t464. 小球
小球
Background
Special for beginners, ^_^
Description
Many balls fall one by one down a full binary tree (, ). At each moment, a falling ball first visits a non-leaf node. As it continues to fall, it goes either into the right subtree or the left subtree, until it reaches a leaf node. The direction a ball takes is determined by the boolean value stored at each node. Initially all nodes are . When a ball visits a node: if the node is , the ball sets it to and then continues its journey down the left subtree; if the node is , the ball sets it to and then continues down the right subtree. The labeling of the full binary tree is shown in the figure below.

Because all nodes are initially , the first ball visits node , node and node , toggles their boolean values, and finally stops at node . The second ball visits node , node and node , and stops at node . Clearly, before it stops, the third ball visits node , node and node , and stops at node .
Your task: given the depth of the and (meaning the -th ball is dropped; you may assume does not exceed the number of leaves of the given ), write a program that finds the leaf number at which the ball stops.
Format
Input
The input consists of a single line containing two integers and separated by a space, where .
Output
Output the leaf number at which the -th ball stops.
Samples
4 2
12
Limitation
1s, 1024KiB for each test case.