#include <bits/stdc++.h>
int const NMAX = 201;
char s[NMAX], t[NMAX], d[NMAX];
int n, q;
int lastposition(int i) {
  int c = i;
  for (int qi = 0; qi < q; qi++) {
    if (s[c] == t[qi]) {
      if (d[qi] == 'L') {
        c--;
        if (c < 0) return -1;
      } else {
        c++;
        if (c >= n) return n;
      }
    }
  }
  return c;
}
int main() {
  scanf("%d%d%s", &n, &q, s);
  for (int i = 0; i < q; i++) {
    char tmp0[2], tmp1[2];
    scanf("%s%s", tmp0, tmp1);
    t[i] = tmp0[0];
    d[i] = tmp1[0];
  }
  if (lastposition(n - 1) == -1 || lastposition(0) == n) {
    printf("0\n");
    return 0;
  }
  int lmin = 0, lmax = n - 1, l;
  while (lmin + 1 < lmax) {
    int lmid = (lmin + lmax) / 2;
    if (lastposition(lmid) >= 0)
      lmax = lmid;
    else
      lmin = lmid;
  }
  if (lastposition(lmin) == -1)
    l = lmax;
  else
    l = lmin;
  int rmin = 0, rmax = n - 1, r;
  while (rmin + 1 < rmax) {
    int rmid = (rmin + rmax) / 2;
    if (lastposition(rmid) < n)
      rmin = rmid;
    else
      rmax = rmid;
  }
  if (lastposition(rmax) == n)
    r = rmin;
  else
    r = rmax;
  printf("%d\n", r - l + 1);
  return 0;
}
