#include <bits/stdc++.h>
using namespace std;
int N, Q;
char s[212345], t[212345], d[212345];
int main() {
  scanf("%d%d%s", &N, &Q, s);
  for (long long i = 0; i < (Q); ++i) scanf("%s%s", &t[i], &d[i]);
  int l = 0, r = N - 1;
  int lmax = -1, rmax = N;
  vector<int> llist, rlist;
  for (long long q = 0; q < (Q); ++q) {
    if (t[q] == s[0] && d[q] == 'L') llist.push_back(q);
    if (t[q] == s[N - 1] && d[q] == 'R') rlist.push_back(q);
  }
  for (auto lli : llist) {
    bool f = true;
    l = 0;
    for (int i = lli - 1; i >= 0; --i) {
      if (t[i] == s[l + 1] && d[i] == 'L') ++l;
      if (t[i] == s[l] && d[i] == 'R') {
        lmax = max(lmax, l - 1);
        f = false;
        l = 0;
        break;
      }
    }
    if (f) lmax = max(lmax, l);
  }
  for (auto rli : rlist) {
    bool f = true;
    r = N - 1;
    for (int i = rli - 1; i >= 0; --i) {
      if (t[i] == s[r - 1] && d[i] == 'R') --r;
      if (t[i] == s[r] && d[i] == 'L') {
        rmax = min(rmax, r + 1);
        f = false;
        break;
      }
    }
    if (f) rmax = min(rmax, r);
  }
  printf("%d\n", max(0, N - (lmax + 1) - (N - rmax)));
  return 0;
}
