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