#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-10;
const double PI = acos(-1.0);
int n, q;
char t[20000], d[20000];
string s;
int bisec(int pos) {
  for (int(i) = 0; (i) < (q); (i)++) {
    if (t[i] == s[pos]) pos += d[i] == 'L' ? -1 : 1;
  }
  if (pos == 0) return -1;
  if (pos == n + 1) return 1;
  return 0;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ans = 0;
  cin >> n >> q;
  cin >> s;
  s = "0" + s + "0";
  for (int(i) = 0; (i) < (q); (i)++) {
    cin >> t[i] >> d[i];
  }
  int l = 0, r = n + 1;
  while (r - l != 1) {
    int c = (l + r) / 2;
    if (bisec(c) == -1)
      l = c;
    else
      r = c;
  }
  int ansl = r;
  l = 0;
  r = n + 1;
  while (r - l != 1) {
    int c = (l + r) / 2;
    if (bisec(c) == 1)
      r = c;
    else
      l = c;
  }
  int ansr = l;
  cout << ansr - ansl + 1 << endl;
  return 0;
}
