#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long f = 1, x = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int stack[20];
inline void write(int x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (!x) {
    putchar('0');
    return;
  }
  int top = 0;
  while (x) stack[++top] = x % 10, x /= 10;
  while (top) putchar(stack[top--] + '0');
}
inline void pr1(int x) {
  write(x);
  putchar(' ');
}
inline void pr2(int x) {
  write(x);
  putchar('\n');
}
const int MAXN = 200005;
char ch[MAXN];
char c1[15], c2[15];
int a[MAXN];
int n, m;
struct oper {
  int x, o;
} w[MAXN];
int hd, tl;
int main() {
  n = read();
  m = read();
  scanf("%s", ch + 1);
  for (int i = 1; i <= n; i++) a[i] = ch[i] - 'A' + 1;
  for (int i = 1; i <= m; i++) {
    scanf("%s", c1 + 1);
    scanf("%s", c2 + 1);
    w[i].x = c1[1] - 'A' + 1;
    if (c2[1] == 'L')
      w[i].o = 0;
    else
      w[i].o = 1;
  }
  hd = 1;
  tl = n;
  for (int i = m; i >= 1; i--) {
    if (hd > tl) break;
    if (w[i].o) {
      if (w[i].x == a[tl]) tl--;
    } else {
      if (w[i].x == a[hd]) hd++;
    }
  }
  if (hd > tl)
    puts("0");
  else
    pr2(tl - hd + 1);
  return 0;
}
