#include <bits/stdc++.h>
using namespace std;
char s[200001];
char t[200000];
int d[200000];
int main() {
  int n, q, l1, r1, m1, l2, r2, m2, i;
  scanf("%d %d", &n, &q);
  scanf("%s", s);
  for (i = 0; i < q; i++) {
    char c1[2];
    char c2[2];
    scanf("%s %s", c1, c2);
    t[i] = c1[0];
    if (c2[0] == 'L') {
      d[i] = -1;
    } else {
      d[i] = 1;
    }
  }
  l1 = -1, r1 = n, m1 = (l1 + r1) / 2;
  while (r1 - l1 > 1) {
    int x = m1;
    for (i = 0; i < q; i++) {
      if (s[x] == t[i]) x += d[i];
      if (x < 0 || x >= n) break;
    }
    if (x < 0) {
      l1 = m1;
      m1 = (l1 + r1) / 2;
    } else {
      r1 = m1;
      m1 = (l1 + r1) / 2;
    }
  }
  l2 = -1, r2 = n, m2 = (l2 + r2) / 2;
  while (r2 - l2 > 2) {
    int x = m2;
    for (i = 0; i < q; i++) {
      if (s[x] == t[i]) x += d[i];
      if (x < 0 || x >= n) break;
    }
    if (x >= n) {
      r2 = m2;
      m2 = (l2 + r2) / 2;
    } else {
      l2 = m2;
      m2 = (l2 + r2) / 2;
    }
  }
  printf("%d\n", n - (l1 + 1) - (n - r2));
  return 0;
}
