#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N, Q;
  scanf("%d %d\n", &N, &Q);
  map<unsigned char, vector<int>> o;
  {
    char S[100000 + 1];
    scanf("%s", S);
    for (int i = 0; S[i]; i++) o[S[i]].emplace_back(i);
  }
  int m[100000];
  for (int n = 0; n < N; n++) m[n] = 1;
  for (int q = 0; q < Q; q++) {
    char t[2], d[2];
    scanf("%s %s", t, d);
    const auto& it = o.find(t[0]);
    if (it == o.end()) continue;
    for (int i : o[t[0]]) {
      int n = d[0] == 'L' ? i - 1 : i + 1;
      if (n >= 0 && n < N) {
        m[n] += m[i];
      }
      m[i] = 0;
    }
  }
  int c = 0;
  for (int n = 0; n < N; n++) c += m[n];
  printf("%d\n", c);
  return 0;
}
