#include <bits/stdc++.h>
using namespace std;
bool vanish(int n, string s, vector<string> t, vector<string> d, int m) {
  int Q = t.size();
  int x = n - 1;
  int L = s.length();
  for (int i = 0; i < Q; i++) {
    if (t[i][0] == s[x]) {
      x += (d[i][0] == 'R' ? 1 : -1);
      if (x == -1 || x == L) break;
    }
  }
  if (x == -1 && m == 0) {
    return true;
  } else if (x == L && m == 1) {
    return true;
  } else {
    return false;
  }
}
int main() {
  int N, Q;
  string s;
  cin >> N >> Q >> s;
  vector<string> t(Q), d(Q);
  for (int i = 0; i < Q; i++) cin >> t[i] >> d[i];
  int Lleft = 0, Lright = N + 1;
  while (Lright - Lleft > 1) {
    int mid = Lleft + (Lright - Lleft) / 2;
    if (vanish(mid, s, t, d, 0)) {
      Lleft = mid;
    } else {
      Lright = mid;
    }
  }
  int Rleft = 0, Rright = N + 1;
  while (Rright - Rleft > 1) {
    int mid = Rleft + (Rright - Rleft) / 2;
    if (vanish(mid, s, t, d, 1)) {
      Rright = mid;
    } else {
      Rleft = mid;
    }
  }
  if (Rleft >= Lright) {
    cout << Rleft - Lright + 1 << endl;
  } else {
    cout << N << endl;
  }
}
