#include <bits/stdc++.h>
using namespace std;
long long n, q, a1, a2, v;
string s;
vector<pair<long long, long long>> p;
bool ok[110000];
bool ss(long long a) {
  long long now = a;
  for (long long i = 0; i < q; i++) {
    if (p[i].first == s[now] - 'A') {
      if (p[i].second == 0)
        now--;
      else
        now++;
      if (now == n or now < 0) return false;
    }
  }
  return true;
}
bool isOK(int index, int key) {
  if (key == 0) {
    if (ss(index))
      return true;
    else
      return false;
  } else {
    if (ss(index)) return false;
    if (ok[index]) return false;
    return true;
  }
}
int bs(int key) {
  int left = -1;
  int right = (int)s.size();
  while (right - left > 1) {
    int mid = left + (right - left) / 2;
    if (isOK(mid, key))
      right = mid;
    else
      left = mid;
  }
  return right;
}
int main() {
  cin >> n >> q;
  cin >> s;
  for (long long i = 0; i < q; i++) {
    char a, b;
    cin >> a >> b;
    long long c = 0;
    if (b == 'R') c++;
    p.push_back(make_pair(a - 'A', c));
  }
  a1 = bs(0);
  for (long long i = 0; i < a1; i++) ok[i] = true;
  a2 = bs(1);
  cout << a2 - a1 << endl;
}
