#include <bits/stdc++.h>
using namespace std;
long N, Q;
string s;
vector<unsigned char> t, d;
bool simulate(int i, unsigned char dir) {
  for (int q = 0; q < Q; q++) {
    if (t[q] == s[i]) {
      if (d[q] == 'L')
        i--;
      else
        i++;
    }
    if (dir == 'L' && i < 0) return true;
    if (dir == 'R' && i >= N) return true;
  }
  return false;
}
int main() {
  cin >> N >> Q >> s;
  t.resize(Q);
  d.resize(Q);
  for (int q = 0; q < Q; q++) cin >> t[q] >> d[q];
  long Lmin = -1;
  long Lmax = N;
  long L;
  while (true) {
    L = (Lmin + Lmax) / 2;
    if (simulate(L, 'L'))
      Lmin = L;
    else
      Lmax = L;
    if (Lmax - Lmin == 1) break;
  }
  long Rmin = -1;
  long Rmax = N;
  long R;
  while (true) {
    R = (Rmin + Rmax) / 2;
    if (simulate(R, 'R'))
      Rmax = R;
    else
      Rmin = R;
    if (Rmax - Rmin == 1) break;
  }
  if (!simulate(R, 'R')) R++;
  cout << N - (L + 1) - (N - R) << endl;
  return 0;
}
