#include <bits/stdc++.h>
using namespace std;
int is_arrive(int start, string& ss, vector<pair<char, int>>& qs) {
  int id = start;
  char s = ss[id];
  for (int i = 0; i < qs.size(); ++i) {
    if (s == qs[i].first) {
      id += qs[i].second;
      s = ss[id];
    }
    if (id == -1) return -1;
    if (id == ss.size()) return 1;
  }
  return 0;
}
int main() {
  int N, Q;
  string ss;
  cin >> N >> Q;
  cin >> ss;
  vector<pair<char, int>> qs;
  for (int i = 0; i < Q; ++i) {
    char t, d;
    cin >> t >> d;
    qs.emplace_back(make_pair(t, d == 'L' ? -1 : 1));
  }
  int imin = 0;
  int imax = N - 1;
  while (imin < imax - 1) {
    int imid = imin + (imax - imin) / 2;
    int ans = is_arrive(imid, ss, qs);
    if (ans < 0) {
      imin = imid;
    } else {
      imax = imid;
    }
  }
  int lu = imin;
  imin = 0;
  imax = N - 1;
  while (imin < imax - 1) {
    int imid = imin + (imax - imin) / 2;
    int ans = is_arrive(imid, ss, qs);
    if (ans > 0) {
      imax = imid;
    } else {
      imin = imid;
    }
  }
  int ru = imax;
  cout << ru - lu - 1 << endl;
  return 0;
}
