#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q, i, j;
  char t, d;
  vector<char> tv, dv;
  string s;
  cin >> n >> q;
  cin >> s;
  int l = -1, r = n;
  int lmax = -1, rmin = n;
  for (i = 0; i < q; i++) {
    cin >> t >> d;
    tv.push_back(t);
    dv.push_back(d);
  }
  for (i = q - 1; i >= 0; i--) {
    t = tv[i];
    d = dv[i];
    if (d == 'L') {
      if (l < n - 2 && s[l + 1] == t) l++;
      if (r < n - 2 && s[r + 1] == t) r++;
    } else {
      if (l > 0 && s[l - 1] == t) l--;
      if (r > 0 && s[r - 1] == t) r--;
    }
    if (l > lmax) lmax = l;
    if (r < rmin) rmin = r;
  }
  cout << max(rmin - lmax - 1, 0) << endl;
}
