#include <bits/stdc++.h>
using namespace std;
long long n, q, l, r, lmax, rmin;
string s;
char t[200010], d[200010];
int main(void) {
  cin >> n >> q >> s;
  s = " " + s;
  for (int i = 0; i < ((int)(q)); i++) cin >> t[i] >> d[i];
  l = 0;
  lmax = 0;
  r = n + 1;
  rmin = n + 1;
  for (int i = ((int)(q)-1); i >= 0; i--) {
    if (l + 1 <= n && t[i] == s[l + 1] && d[i] == 'L') {
      l++;
      lmax = max(lmax, l);
    }
    if (r - 1 >= 1 && t[i] == s[r - 1] && d[i] == 'R') {
      r--;
      rmin = min(rmin, r);
    }
  }
  cout << n - min(n, lmax + (n + 1 - rmin)) << endl;
  return 0;
}
