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