#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N, Q;
  string s;
  cin >> N >> Q;
  cin >> s;
  vector<char> qchar(Q);
  vector<int> qdir(Q);
  for (int i = 0; i < Q; i++) {
    char d;
    cin >> qchar[i] >> d;
    qdir[i] = (d == 'L') ? -1 : 1;
  }
  s = "l" + s + "r";
  int lleft = 0, lright = N + 2, lcenter = (lleft + lright) / 2;
  int rleft = 0, rright = N + 2, rcenter = (rleft + rright) / 2;
  for (; lleft < lright || rleft < rright;
       lcenter = (lleft + lright) / 2, rcenter = (rleft + rright) / 2) {
    char* lpos = &s[lcenter];
    char* rpos = &s[rcenter];
    for (int turn = 0; turn < qchar.size(); turn++) {
      if (qchar[turn] == *lpos) {
        lpos += qdir[turn];
      }
      if (qchar[turn] == *rpos) {
        rpos += qdir[turn];
      }
    }
    if (*lpos == 'l') {
      lleft = lcenter + 1;
    } else {
      lright = lcenter;
    }
    if (*rpos == 'r') {
      rright = rcenter - 1;
    } else {
      rleft = rcenter;
    }
  }
  cout << rcenter - lcenter + 1 << endl;
  return 0;
}
