#include <bits/stdc++.h>
using namespace std;
const int MAXT = 62;
int R, C, T;
char c[MAXT];
long long r1score[MAXT];
long long rscore[MAXT];
long long lscore[MAXT];
long long mval;
map<pair<long long, int>, long long> mmap;
map<pair<long long, int>, long long> nmap;
long long choose(int x, int y) {
  if (y > x || y < 0) return 0;
  long long res = 1;
  for (int i = 0; i < y; i++) {
    res = res * (x - i);
    res = res / (i + 1);
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> R >> C;
  T = (2 * R + 2 * C);
  for (int i = 0; i < T; i++) cin >> c[i];
  for (int i = 0; i < MAXT; i++) lscore[i] = 0;
  lscore[2 * R - 1] = 1;
  for (int i = 2 * R; i < T; i++) {
    lscore[i] = lscore[i - 1] * i / ((long long)i - 2 * R + 1);
  }
  for (int i = 0; i <= T; i++) {
    r1score[i] = choose(i, R - 1);
    rscore[i] = choose(i, R);
  }
  mval = 0;
  int acnt = 0, bcnt = 0;
  for (int i = T - 1; i >= 0; i--) {
    bool u = mval > 0;
    if (bcnt == T / 2) u = true;
    if (acnt == T / 2) u = false;
    if (u) {
      acnt++;
      mval -= r1score[T / 2 - acnt] * rscore[T / 2 - bcnt];
    } else {
      bcnt++;
      mval += r1score[T / 2 - bcnt] * rscore[T / 2 - acnt];
    }
  }
  mval = max(mval, -mval);
  long long tsum = 0;
  for (int i = 0; i < T; i++) {
    tsum += lscore[i];
  }
  tsum = rscore[T / 2] * rscore[T / 2];
  mmap[make_pair(0, 0)] = 1;
  for (int i = T - 1; i >= 2 * R - 1; i--) {
    nmap.clear();
    for (map<pair<long long, int>, long long>::iterator it = mmap.begin();
         it != mmap.end(); it++) {
      long long sum = it->first.first;
      long long acnt = it->first.second;
      long long ncount = it->second;
      int aleft = T / 2 - acnt;
      int bleft = i + 1 - aleft;
      long long asum = sum + r1score[aleft - 1] * rscore[bleft];
      long long bsum = sum - r1score[bleft - 1] * rscore[aleft];
      if (c[i] == 'A') {
        nmap[make_pair(asum, acnt + 1)] += ncount;
        nmap[make_pair(bsum, acnt)] += 0;
      } else if (c[i] == 'B') {
        nmap[make_pair(asum, acnt + 1)] += 0;
        nmap[make_pair(bsum, acnt)] += ncount;
      } else {
        nmap[make_pair(asum, acnt + 1)] += ncount;
        nmap[make_pair(bsum, acnt)] += ncount;
      }
    }
    tsum -= lscore[i];
    mmap.clear();
    for (map<pair<long long, int>, long long>::iterator it = nmap.begin();
         it != nmap.end(); it++) {
      long long sum = it->first.first;
      int acnt = it->first.second;
      long long ncount = it->second;
      int aleft = T / 2 - acnt;
      int bleft = i - aleft;
      if (acnt > (T / 2) || (T - i - acnt) > (T / 2)) continue;
      long long lsum = rscore[aleft] * rscore[bleft];
      if (sum < (-mval - lsum) || sum > (mval + lsum)) continue;
      mmap[make_pair(sum, acnt)] += ncount;
    }
  }
  long long bscore = (long long)1e18;
  for (map<pair<long long, int>, long long>::iterator it = mmap.begin();
       it != mmap.end(); it++) {
    long long sum = it->first.first;
    bscore = min(bscore, max(sum, -sum));
  }
  long long ans = 0;
  for (map<pair<long long, int>, long long>::iterator it = mmap.begin();
       it != mmap.end(); it++) {
    long long sum = it->first.first;
    int acnt = it->first.second;
    long long ncount = it->second;
    if (sum == bscore || sum == -bscore) {
      int nleft = 0;
      for (int i = 0; i < 2 * R - 1; i++) {
        if (c[i] == 'A') acnt++;
        if (c[i] == '?') nleft++;
      }
      ncount *= choose(nleft, T / 2 - acnt);
      ans += ncount;
    }
  }
  cout << ans << "\n";
  return 0;
}
