Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

F. Egg Roulette

time limit per test

3 secondsmemory limit per test

256 megabytesinput

standard inputoutput

standard outputThe game of Egg Roulette is played between two players. Initially 2*R* raw eggs and 2*C* cooked eggs are placed randomly into a carton. The shells are left on so there is no way to distinguish a raw egg from a cooked egg. One at a time, a player will select an egg, and then smash the egg on his/her forehead. If the egg was cooked, not much happens, but if the egg was raw, it will make quite the mess. This continues until one player has broken *R* raw eggs, at which point that player is declared the loser and the other player wins.

The order in which players take turns can be described as a string of 'A' and 'B' characters, where the *i*-th character tells which player should choose the *i*-th egg. Traditionally, players take turns going one after the other. That is, they follow the ordering "ABABAB...". This isn't very fair though, because the second player will win more often than the first. We'd like you to find a better ordering for the players to take their turns. Let's define the unfairness of an ordering as the absolute difference between the first player's win probability and the second player's win probability. We're interested in orderings that minimize the unfairness. We only consider an ordering valid if it contains the same number of 'A's as 'B's.

You will also be given a string *S* of length 2(*R* + *C*) containing only 'A', 'B', and '?' characters. An ordering is said to match *S* if it only differs from *S* in positions where *S* contains a '?'. Of the valid orderings that minimize unfairness, how many match *S*?

Input

The first line of input will contain integers *R* and *C* (1 ≤ *R*, *C* ≤ 20, *R* + *C* ≤ 30).

The second line of input will contain the string *S* of length 2(*R* + *C*) consisting only of characters 'A', 'B', '?'.

Output

Print the number of valid orderings that minimize unfairness and match *S*.

Examples

Input

1 1

??BB

Output

0

Input

2 4

?BA??B??A???

Output

1

Input

4 14

????A??BB?????????????AB????????????

Output

314

Note

In the first test case, the minimum unfairness is 0, and the orderings that achieve it are "ABBA" and "BAAB", neither of which match *S*. Note that an ordering such as "ABBB" would also have an unfairness of 0, but is invalid because it does not contain the same number of 'A's as 'B's.

In the second example, the only matching ordering is "BBAAABABABBA".

Codeforces (c) Copyright 2010-2020 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Jun/06/2020 11:45:57 (f1).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|