#include <bits/stdc++.h>
using namespace std;
signed main() {
  int n, q;
  int Rcheck = 0, Lcheck = 0, allcheck = 0;
  int rp, lp, rmax = 0, lmax = 0;
  cin >> n >> q;
  rp = n - 1;
  lp = 0;
  vector<char> s(n);
  vector<char> t(q);
  vector<char> d(q);
  for (int i = 0; (i) < (n); ++(i)) cin >> s[i];
  for (int i = 0; (i) < (q); ++(i)) cin >> t[q - i - 1] >> d[q - i - 1];
  for (int i = 0; (i) < (q); ++(i)) {
    if (rp == 0 || lp == n - 1 || rmax + lmax >= n) {
      allcheck++;
      break;
    }
    if (t[i] == s[0] && d[i] == 'L' && Lcheck == 0) {
      Lcheck = 1;
      lmax++;
      continue;
    }
    if (t[i] == s[n - 1] && d[i] == 'R' && Rcheck == 0) {
      Rcheck = 1;
      rmax++;
      continue;
    }
    if (Rcheck == 1) {
      if (t[i] == s[rp - 1] && d[i] == 'R') {
        rp--;
      } else if (rp != n - 1) {
        if (t[i] == s[rp + 1] && d[i] == 'L') {
          rp++;
        }
      }
      rmax = max(rmax, n - rp);
    }
    if (Lcheck == 1) {
      if (t[i] == s[lp + 1] && d[i] == 'L') {
        lp++;
      } else if (rp != 0) {
        if (t[i] == s[lp - 1] && d[i] == 'R') {
          lp--;
        }
      }
      lmax = max(lmax, lp + 1);
    }
  }
  if (allcheck)
    cout << 0 << endl;
  else
    cout << n - rmax - lmax << endl;
  return 0;
}
