Numbers on a Tree

No attempts yetTime limit1sMemory limit256 MB

Problem

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 HH has H+1H+1 layers: the root sits at depth 00 and the leaves at depth HH.

The nodes are labeled by the following rule. The bottom right leaf gets label 11, and within the same layer the labels increase by 11 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 33. Path LR leads to the node labeled 1111, and path RRL leads to the node labeled 22. The root is labeled 1515.

Given the height HH of the tree and a path starting at the root, compute the label of the node that the path reaches.

Input

The first line contains the height HH of the tree and one string, separated by a space (1H301 \le H \le 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 HH. If the path is empty, the first line contains only HH.

Output

Print the label of the node that the path reaches on one line.