#include <bits/stdc++.h>
using namespace std;
const int64_t INF = 100000000;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int64_t N, Q;
  cin >> N >> Q;
  string s;
  cin >> s;
  vector<char> t(Q), d(Q);
  for (int64_t i = 0; i < Q; i++) {
    cin >> t.at(i) >> d.at(i);
  }
  int64_t LL, RR;
  LL = -1;
  RR = N;
  for (int64_t i = Q - 1; i >= 0; i--) {
    if (t.at(i) == s.at(LL + 1) && d.at(i) == 'L') LL = LL + 1;
    if (t.at(i) == s.at(RR - 1) && d.at(i) == 'R') RR = RR - 1;
    if (LL != -1) {
      if (t.at(i) == s.at(LL) && d.at(i) == 'R') LL = LL - 1;
    }
    if (RR != N) {
      if (t.at(i) == s.at(RR) && d.at(i) == 'L') RR = RR + 1;
    }
  }
  int64_t zero = 0;
  cout << max(zero, RR - LL - 1) << endl;
}
