#include <bits/stdc++.h>
using namespace std;
int in() {
  int x;
  scanf("%d", &x);
  return x;
}
string stin() {
  string s;
  cin >> s;
  return s;
}
long long lin() {
  long long x;
  scanf("%lld", &x);
  return x;
}
int n, q;
string s;
vector<pair<char, bool>> v;
int f(int k) {
  int tmp_x = k;
  char tmp_c = s[k];
  for (auto x : v) {
    if (x.first == tmp_c) {
      if (x.second)
        tmp_x++;
      else
        tmp_x--;
      if (tmp_x == -1)
        return -1;
      else if (tmp_x == n)
        return 1;
      else
        tmp_c = s[tmp_x];
    }
  }
  return 0;
}
int main() {
  n = in();
  v.resize(q = in());
  s = stin();
  for (int i = 0; i < q; i++) {
    char c;
    cin >> c;
    bool bl = stin() == "R" ? 1 : 0;
    v[i] = make_pair(c, bl);
  }
  int l = 0, r = n + 1, x = 0, y = 0;
  while (l + 1 < r) {
    x = (l + r) / 2;
    if (f(x) == -1)
      l = x;
    else
      r = x;
  }
  l = 0;
  r = n;
  while (l + 1 < r) {
    y = (l + r) / 2;
    if (f(y) == 1)
      r = y;
    else
      l = y;
  }
  cout << y - x + 1 << endl;
}
