#include <bits/stdc++.h>
int main() {
  long i, j, n, q, sum = 0;
  long *block;
  char *str;
  char t[2], d[2];
  scanf("%ld %ld", &n, &q);
  block = (long *)malloc(n * sizeof(long));
  str = (char *)malloc(n * sizeof(char));
  scanf("%s", str);
  for (i = 0; i < n; i++) {
    block[i] = 1;
  }
  for (i = 0; i < q; i++) {
    scanf("%s %s", t, d);
    if (d[0] == 'L') {
      if (str[0] == t[0]) {
        sum += block[0];
        block[0] = 0;
      }
      for (j = 1; j < n; j++) {
        if (str[j] == t[0]) {
          block[j - 1] += block[j];
          block[j] = 0;
        }
      }
    } else {
      if (str[n - 1] == t[0]) {
        sum += block[n - 1];
        block[n - 1] = 0;
      }
      for (j = n - 2; j >= 0; j--) {
        if (str[j] == t[0]) {
          block[j + 1] += block[j];
          block[j] = 0;
        }
      }
    }
  }
  printf("%ld", n - sum);
  free(block);
  free(str);
  return 0;
}
