#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 200000;
const int MAX_Q = 200000;
enum { STAY, LOUT, ROUT };
char s[MAX_N + 4];
pair<char, int> ops[MAX_Q];
int check(int n, int q, int x) {
  for (int i = 0; i < q; i++)
    if (s[x] == ops[i].first) {
      x += ops[i].second;
      if (x < 0) return LOUT;
      if (x >= n) return ROUT;
    }
  return STAY;
}
int main() {
  int n, q;
  scanf("%d%d%s", &n, &q, s);
  for (int i = 0; i < q; i++) {
    char st[4], sd[4];
    scanf("%s%s", st, sd);
    ops[i] = pair<char, int>(st[0], (sd[0] == 'L') ? -1 : 1);
  }
  int l0 = -1, r0 = n - 1;
  while (l0 + 1 < r0) {
    int x = (l0 + r0) / 2;
    if (check(n, q, x) == LOUT)
      l0 = x;
    else
      r0 = x;
  }
  int l1 = 0, r1 = n;
  while (l1 + 1 < r1) {
    int x = (l1 + r1) / 2;
    if (check(n, q, x) == ROUT)
      r1 = x;
    else
      l1 = x;
  }
  printf("%d\n", r1 - r0);
  return 0;
}
