A perfect binary tree has a single root at the top, and every node except the leaves in the lowest layer has exactly two children. A tree of height H has H+1 layers: the root sits at depth 0 and the leaves at depth H.
The nodes are labeled by the following rule. The bottom right leaf gets label 1, and within the same layer the labels increase by 1 as you move from right to left. Once a layer is finished, move up to the rightmost node of the layer above and label that layer from right to left as well. Repeat until the root is labeled.
A node of the tree can be described by a path that starts at the root and goes down. At a node that is not a leaf you can go to the left child (L) or to the right child (R).

Figure: a labeled tree of height 3. Path LR leads to the node labeled 11, and path RRL leads to the node labeled 2. The root is labeled 15.
Given the height H of the tree and a path starting at the root, compute the label of the node that the path reaches.
The first line contains the height H of the tree and one string, separated by a space (1≤H≤30). The string consists only of the letters L and R and describes a path starting at the root. L means going to the left child, and R means going to the right child. The path can be empty, and its length is at most H. If the path is empty, the first line contains only H.
Print the label of the node that the path reaches on one line.