#include <bits/stdc++.h>
int main() {
  int N, Q, i, j, sum = 0, *g;
  char *s, t, d, tmp;
  scanf("%d %d\n", &N, &Q);
  s = (char *)malloc(N + 100);
  g = (int *)malloc(N + 100);
  scanf("%s", s);
  for (i = 0; i < N + 1; i++) g[i] = 1;
  for (i = 0; i < Q; i++) {
    scanf("%*c%c %c", &t, &d);
    if (d == 'L') {
      for (j = 0; j < N; j++) {
        if (s[j] == t) {
          if (j != 0) g[j - 1] += g[j];
          g[j] = 0;
        }
      }
    } else {
      for (j = N - 1; j >= 0; j--) {
        if (s[j] == t) {
          if (j != N - 1) g[j + 1] += g[j];
          g[j] = 0;
        }
      }
    }
  }
  for (i = 0; i < N; i++) sum += g[i];
  printf("%d\n", sum);
  free(s);
  free(g);
  return 0;
}
