Dragon Pattern

No attempts yetTime limit5sMemory limit128 MB

Problem

The dragon curve is a polygonal chain built from segments of length 1, defined recursively. Choose a point in the plane and one of the four directions parallel to the coordinate axes. The left (right) dragon of order nn is drawn like this:

  • if nn is 0, draw a segment of length 1 from the current point in the current direction and move to its endpoint;
  • otherwise draw the left dragon of order n1n-1 from the current point in the current direction, turn 90 degrees to the left (right) at the endpoint, then draw the right dragon of order n1n-1.

Draw the left dragon of order nn starting at the origin (0,0)(0, 0) in the positive direction of the axis OXOX. It makes 2n2^n moves of length 1 one after another, so writing down the direction of each move in order gives a string of length 2n2^n.

A pattern is also a string of move directions. Count the substrings of that direction string that equal the pattern, that is, the number of positions where the pattern starts.

Input

One line contains an integer nn and a string SS describing the pattern, separated by one space. SS consists only of the letters R, L, U, D. R means a move to the right (positive direction of the axis OXOX), L a move to the left (negative direction of OXOX), U a move up (positive direction of the axis OYOY), and D a move down (negative direction of OYOY).

0n1090 \le n \le 10^9 and 1S1061 \le |S| \le 10^6.

Output

Print how many times the pattern SS occurs in the left dragon of order nn drawn in the positive direction of the axis OXOX, modulo 109+710^9+7.