#include <bits/stdc++.h>
using namespace std;
int N, Q;
int A[100005];
vector<pair<int, int> > VQ;
int fall(int qu, int po) {
  if (qu == Q) return 0;
  if (VQ[qu].first != A[po]) return fall(qu + 1, po);
  if (VQ[qu].second == 0) {
    if (po == 1)
      return -1;
    else
      return fall(qu + 1, po - 1);
  } else {
    if (po == N)
      return 1;
    else
      return fall(qu + 1, po + 1);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> Q;
  string str;
  cin >> str;
  for (int i = 1; i <= N; i++) A[i] = str[i - 1] - 'A';
  int ch, di;
  for (int i = 1; i <= Q; i++) {
    cin >> str;
    ch = str[0] - 'A';
    cin >> str;
    di = (str[0] == 'L') ? 0 : 1;
    VQ.push_back(make_pair(ch, di));
  }
  int rm, lm;
  int lo, hi;
  lo = 0, hi = N + 1;
  while (lo + 1 < hi) {
    int md = (lo + hi) / 2;
    if (fall(0, md) == -1)
      lo = md;
    else
      hi = md;
  }
  rm = lo;
  lo = 0, hi = N + 1;
  while (lo + 1 < hi) {
    int md = (lo + hi) / 2;
    if (fall(0, md) == 1)
      hi = md;
    else
      lo = md;
  }
  lm = hi;
  cout << N - rm - (N + 1 - lm) << '\n';
  return 0;
}
