#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q;
  string s;
  cin >> n >> q >> s;
  char t[q], d[q];
  for (int i = 0; i < q; i++) cin >> t[i] >> d[i];
  int l = -1;
  int lMax = -1;
  int r = n;
  int rMin = n;
  for (int i = q - 1; i >= 0; i--) {
    if (t[i] == s[l + 1]) {
      if (!(l == -1 && d[i] == 'R'))
        if (d[i] == 'L')
          l++;
        else
          l--;
      if (lMax < l) lMax = l;
    }
    if (t[i] == s[r - 1]) {
      if (!(r == n && d[i] == 'L'))
        if (d[i] == 'L')
          r++;
        else
          r--;
      if (rMin > r) rMin = r;
    }
  }
  cout << ((rMin < lMax) ? 0 : lMax + (n - rMin) - 1) << endl;
  return 0;
}
