#include <bits/stdc++.h>
using namespace std;
const int INF = 2147483647;
const int N = 200005;
int n, q, pos[N], kier[N], res, i, j, po, akt, a, b, ind[30];
vector<pair<int, int> > w;
vector<int> v[30];
map<pair<int, int>, int> mapa;
char t[N];
int main() {
  scanf("%d %d", &n, &q);
  scanf("%s", t);
  for (i = 0; i < n; i++) pos[i] = int(t[i] - 'A');
  for (i = 0; i < q; i++) {
    scanf("%s", t);
    v[int(t[0] - 'A')].push_back(i);
    scanf("%s", t);
    kier[i] = (t[0] == 'R');
  }
  res = 0;
  for (i = 0; i < n; i++) {
    for (j = 0; j < 26; j++) ind[j] = 0;
    akt = 0;
    po = i;
    w.clear();
    while (true) {
      a = pos[po];
      if (mapa.find(pair<int, int>(po, akt)) != mapa.end()) {
        po = mapa[pair<int, int>(po, akt)];
        break;
      }
      w.push_back(pair<int, int>(po, akt));
      while (ind[a] < v[a].size() && v[a][ind[a]] < akt) ind[a]++;
      if (ind[a] >= v[a].size()) break;
      b = v[a][ind[a]];
      if (kier[b])
        po++;
      else
        po--;
      if (po == -1 || po == n) break;
      akt = b + 1;
    }
    for (pair<int, int> &q : w) mapa[q] = po;
    if (po >= 0 && po < n) res++;
  }
  printf("%d\n", res);
  return 0;
}
