#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 r = n;
  for (int i = q - 1; i >= 0; i--) {
    if (t[i] == s[l + 1] && d[i] == 'L') l++;
    if (t[i] == s[r - 1] && d[i] == 'R') r--;
  }
  cout << ((r < l) ? 0 : n - (l + 1) - (n - r)) << endl;
  return 0;
}
