#include <bits/stdc++.h>
int main() {
  int i, n, q, left, right;
  char *s, *t, *d;
  scanf("%d%d", &n, &q);
  if ((s = (char *)malloc(sizeof(char) * (n + 1))) == 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 = q - 1, left = 0, right = n - 1; i >= 0; i--) {
    switch (d[i]) {
      case 'L':
        if (s[left] == t[i]) left++;
        break;
      case 'R':
        if (s[right] == t[i]) right--;
        break;
    }
  }
  printf("%d\n", right - left + 1);
  free(s);
  free(t);
  free(d);
  return 0;
}
