#include <bits/stdc++.h>
using namespace std;
bool isOK(int c, string &s, vector<char> &t, vector<char> &d, bool isL) {
  for (int i = 0; i < t.size(); i++) {
    if (s[c] == t[i]) {
      c += (d[i] == 'L' ? -1 : 1);
    }
  }
  if (isL) {
    if (c < 0)
      return true;
    else
      return false;
  } else {
    if (c >= s.size())
      return true;
    else
      return false;
  }
}
int main() {
  int N, Q;
  cin >> N >> Q;
  string s;
  cin >> s;
  vector<char> t(Q), d(Q);
  for (int i = 0; i < Q; i++) {
    cin >> t[i] >> d[i];
  }
  int ok = -1, ng = N;
  while (abs(ng - ok) > 1) {
    int c = (ng + ok) / 2;
    if (isOK(c, s, t, d, true))
      ok = c;
    else
      ng = c;
  }
  int ok_l = ok;
  ok = N, ng = -1;
  while (abs(ng - ok) > 1) {
    int c = (ng + ok) / 2;
    if (isOK(c, s, t, d, false))
      ok = c;
    else
      ng = c;
  }
  int ok_r = ok;
  cout << (ok_r - ok_l - 1) << endl;
  return 0;
}
