#include <bits/stdc++.h>
int i, j, k[26], l, N, Q, G[200010], X, ABC[26][200010] = {0};
char S[200010], t[200010], d[200010];
int main(void) {
  scanf("%d%d\n", &N, &Q);
  scanf("%s\n", &S);
  for (j = 0; j < Q; j++) scanf("%c%*c%c%*c", &t[j], &d[j]);
  for (i = 0; i < N; i++) G[i] = 1;
  for (i = 0; i < N; i++) {
    ABC[S[i] - 'A'][k[S[i] - 'A']++] = i;
  }
  for (j = 0; j < Q; j++) {
    for (l = 0; l < k[t[j] - 'A']; l++) {
      if (d[j] == 'R') {
        if (ABC[t[j] - 'A'][l] == N - 1)
          G[N - 1] = 0;
        else {
          G[ABC[t[j] - 'A'][l] + 1] += G[ABC[t[j] - 'A'][l]];
          G[ABC[t[j] - 'A'][l]] = 0;
        }
      } else {
        if (ABC[t[j] - 'A'][l] == 0)
          G[0] = 0;
        else {
          G[ABC[t[j] - 'A'][l] - 1] += G[ABC[t[j] - 'A'][l]];
          G[ABC[t[j] - 'A'][l]] = 0;
        }
      }
    }
  }
  X = 0;
  for (i = 0; i < N; i++) X += G[i];
  printf("%d\n", X);
  return 0;
}
