#include <bits/stdc++.h>
using namespace std;
int n, q;
string s;
char t[114514], d[114514];
int sim(int pos) {
  for (int i = 0; i < q; i++) {
    if (t[i] == s[pos]) {
      pos += (d[i] == 'R') ? 1 : -1;
    }
    if (pos < 0) return -1;
    if (pos >= n) return 1;
  }
  return 0;
}
int main(void) {
  cin >> n >> q;
  cin >> s;
  for (int i = 0; i < q; i++) cin >> t[i] >> d[i];
  int lo = -1, hi = n, mid1, mid2;
  while (lo + 1 < hi) {
    mid1 = (lo + hi) / 2;
    if (sim(mid1) == -1) {
      lo = mid1;
    } else {
      hi = mid1;
    }
  }
  int left = lo;
  lo = -1, hi = n;
  while (lo + 1 < hi) {
    mid2 = (lo + hi) / 2;
    if (sim(mid2) == 1) {
      hi = mid2;
    } else {
      lo = mid2;
    }
  }
  int right = lo;
  cout << right - left << endl;
  return 0;
}
