#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, Q;
  cin >> N >> Q;
  string s;
  cin >> s;
  vector<char> t(Q), d(Q);
  for (int i = 0; i < (int)(Q); ++i) cin >> t[i] >> d[i];
  int ans_left, ans_right;
  int left = 0, right = N - 1;
  while (left < right) {
    int mid = (left + right) / 2;
    int pos = mid;
    for (int i = 0; i < (int)(Q); ++i) {
      if (t[i] == s[pos]) {
        if (d[i] == 'L') --pos;
        if (d[i] == 'R') ++pos;
        if (pos < 0) {
          left = mid + 1;
          break;
        }
        if (pos >= N) break;
      }
    }
    if (pos >= 0) right = mid;
  }
  ans_left = left;
  left = 0, right = N - 1;
  while (left < right) {
    int mid = (left + right + 1) / 2;
    int pos = mid;
    for (int i = 0; i < (int)(Q); ++i) {
      if (t[i] == s[pos]) {
        if (d[i] == 'L') --pos;
        if (d[i] == 'R') ++pos;
        if (pos < 0) break;
        if (pos >= N) {
          right = mid - 1;
          break;
        }
      }
    }
    if (pos < N) left = mid;
  }
  ans_right = right;
  cout << max(0, ans_right - ans_left + 1) << endl;
  return 0;
}
