#include <bits/stdc++.h>
using namespace std;
void solve() {
  int i, j, k, l, r, x, y;
  string s;
  bool exit = false;
  int N, Q;
  cin >> N >> Q;
  cin >> s;
  vector<char> t(Q);
  vector<char> d(Q);
  for (i = 0; i < (Q); i++) {
    cin >> t[i];
    cin >> d[i];
  }
  int cnt_R = 0;
  int cnt_L = 0;
  int cnt = 0;
  for (i = Q - 1; i >= 0; i--) {
    if (t[i] == s[cnt] && d[i] == 'L') {
      cnt += 1;
    }
    if (cnt == 0) continue;
    if (cnt - 1 > N - 1) {
      cnt_R = N;
      break;
    }
    if (t[i] == s[cnt - 1] && d[i] == 'R') {
      cnt_L = max(cnt_L, cnt);
      cnt = 0;
    }
  }
  cnt_L = max(cnt_L, cnt);
  cnt = 0;
  for (i = Q - 1; i >= 0; i--) {
    if (t[i] == s[N - 1 - cnt] && d[i] == 'R') {
      cnt += 1;
    }
    if (cnt == 0) continue;
    if (cnt - 1 > N - 1) {
      cnt_R = N;
      break;
    }
    if (t[i] == s[N - 1 - (cnt - 1)] && d[i] == 'L') {
      cnt_R = max(cnt_R, cnt);
      cnt = 0;
    }
  }
  cnt_R = max(cnt_R, cnt);
  int ret = N - cnt_R - cnt_L;
  if (ret < 0) ret = 0;
  cout << ret << endl;
}
int main(int argc, char** argv) {
  string s;
  int i;
  if (argc == 1) ios::sync_with_stdio(false), cin.tie(0);
  for (i = 0; i < (argc - 1); i++) s += argv[i + 1], s += '\n';
  for (i = 0; i < (s.size()); i++) ungetc(s[s.size() - 1 - i], stdin);
  cout.tie(0);
  solve();
  return 0;
}
