#include <bits/stdc++.h>
using namespace std;
bool checkLeft(int x, int k, string &s, vector<char> &t, vector<char> &d) {
  for (int i = 0; i < t.size(); ++i) {
    if (t[i] == s[x]) {
      if (d[i] == 'L') {
        --x;
      } else {
        ++x;
      }
    }
    if (s[x] == '_') {
      return x == k;
    }
  }
  return false;
}
int main() {
  int n, q;
  string s;
  cin >> n >> q;
  cin >> s;
  s = "_" + s + "_";
  vector<char> t(q);
  vector<vector<char> > d(2, vector<char>(q));
  for (int i = 0; i < q; ++i) {
    cin >> t[i] >> d[0][i];
    d[1][i] = (d[0][i] == 'L' ? 'R' : 'L');
  }
  int bounds[2];
  int golem = n;
  for (int i = 0; i < 2; ++i) {
    int lb = 0, m, ub = n + 1;
    while (ub - lb > 1) {
      m = (ub + lb) / 2;
      if (checkLeft(m, 0, s, t, d[i])) {
        lb = m;
      } else {
        ub = m;
      }
    }
    reverse(s.begin(), s.end());
    bounds[i] = lb;
    golem -= lb;
  }
  cout << golem << endl;
}
