#include <bits/stdc++.h>
int main() {
  int i, j, n, q, *num_golem, sum;
  char *s, *t, *d;
  scanf("%d%d", &n, &q);
  if ((s = (char *)malloc(sizeof(char) * (n + 1))) == NULL) return 1;
  if ((num_golem = (int *)malloc(sizeof(int) * n)) == NULL) return 1;
  scanf("%s", s);
  if ((t = (char *)malloc(sizeof(char) * q)) == NULL) return 1;
  if ((d = (char *)malloc(sizeof(char) * q)) == NULL) return 1;
  for (i = 0; i < q; i++) {
    scanf("\n%c %c", t + i, d + i);
  }
  for (i = 0; i < n; i++) num_golem[i] = 1;
  for (i = 0; i < q; i++) {
    switch (d[i]) {
      case 'L':
        if (t[i] == s[0]) num_golem[0] = 0;
        for (j = 1; j < n; j++) {
          if (t[i] == s[j]) {
            num_golem[j - 1] += num_golem[j];
            num_golem[j] = 0;
          }
        }
        break;
      case 'R':
        if (t[i] == s[n - 1]) num_golem[n - 1] = 0;
        for (j = n - 2; j >= 0; j--) {
          if (t[i] == s[j]) {
            num_golem[j + 1] += num_golem[j];
            num_golem[j] = 0;
          }
        }
        break;
    }
  }
  for (i = 0, sum = 0; i < n; i++) sum += num_golem[i];
  printf("%d\n", sum);
  free(s);
  free(num_golem);
  free(t);
  free(d);
  return 0;
}
