#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, Q;
  cin >> N >> Q;
  string s;
  cin >> s;
  vector<char> t(200009), d(200009);
  for (int i = 0; i < Q; i++) cin >> t[i] >> d[i];
  int cnt = 0;
  int sum = 0;
  int r = 0;
  for (int i = Q - 1; i >= 0; i--) {
    if (cnt > 0 && s[cnt - 1] == t[i] && d[i] == 'R') {
      cnt--;
      if (r < cnt) {
        r = cnt;
      }
      cnt = 0;
    } else if (s[cnt] == t[i] && d[i] == 'L') {
      cnt++;
    }
    if (cnt == N) {
      break;
    }
  }
  sum += max(r, cnt);
  cnt = 0;
  r = 0;
  for (int i = Q - 1; i >= 0; i--) {
    if (cnt > 0 && s[N - 1 - (cnt - 1)] == t[i] && d[i] == 'L') {
      cnt--;
      if (r < cnt) {
        r = cnt;
      }
      cnt = 0;
    } else if (s[N - 1 - cnt] == t[i] && d[i] == 'R') {
      cnt++;
    }
    if (cnt == N) {
      break;
    }
  }
  sum += max(r, cnt);
  cout << max(N - sum, 0) << endl;
}
