#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q;
  string s;
  cin >> n >> q >> s;
  vector<pair<char, char>> qry(q);
  for (int i = 0; i < q; i++) {
    char t, d;
    cin >> t >> d;
    qry[i] = {t, d};
  }
  int lft = 0;
  for(int i = q - 1; i >= 0; i--) {
    char t = qry[i].first;
    char d = qry[i].second;
    if (0 <= lft && t == s[lft] && d == 'L') {
      lft++;
    } else if (0 < lft && t == s[lft - 1] && d == 'R') {
      lft--;
    }
    if (lft == n) break;
  }
  int rgt = n;
  for(int i = q - 1; i >= 0; i--) {
    char t = qry[i].first;
    char d = qry[i].second;
    if (rgt < n && t == s[rgt] && d == 'L') {
      rgt++;
    } else if (rgt <= n && t == s[rgt - 1] && d == 'R') {
      rgt--;
    }
    if (rgt == -1) break;
  }
  int ret = rgt - lft;
  ret = max(ret, 0);
  cout << ret << '\n';
  return 0;
}