#include <bits/stdc++.h>
using namespace std;
int main() {
  int n = 8, q = 3;
  string s("AABCBDBA");
  cin >> n >> q;
  cin >> s;
  vector<char> vt(q, 0);
  vector<char> vd(q, 0);
  for (int i = 0; i < q; ++i) {
    cin >> vt[i] >> vd[i];
  }
  vector<int> board(n, 1);
  vector<int> bocnt(n, 1);
  for (int i = 0; i < n; ++i) {
    board[i] = (1 << int(s[i] - 'A'));
  }
  for (int i = 0; i < q; ++i) {
    int check = 1 << int(vt[i] - 'A');
    if (vd[i] == 'L') {
      for (int i = 0; i < n; ++i) {
        if ((board[i] & check) == 0) {
          continue;
        }
        if (i > 0) {
          board[i - 1] |= board[i];
          bocnt[i - 1] += bocnt[i];
        }
        board[i] = 0;
        bocnt[i] = 0;
      }
    } else {
      for (int i = n - 1; i >= 0; --i) {
        if ((board[i] & check) == 0) {
          continue;
        }
        if (i < n - 1) {
          board[i + 1] |= board[i];
          bocnt[i + 1] += bocnt[i];
        }
        board[i] = 0;
        bocnt[i] = 0;
      }
    }
  }
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    cnt += bocnt[i];
  }
  cout << cnt << endl;
  return 0;
}
