#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, Q;
  char s[200001];
  char t[200001];
  char d[200001];
  cin >> N >> Q;
  for (int i = 0; i < N; i++) cin >> s[i];
  for (int i = 0; i < Q; i++) cin >> t[i] >> d[i];
  int head = 0;
  int tail = N - 1;
  for (int i = Q - 1; i >= 0; i--) {
    if (s[head] == t[i] && d[i] == 'L') {
      head++;
    }
    if (s[tail] == t[i] && d[i] == 'R') {
      tail--;
    }
  }
  cout << tail - head + 1 << endl;
  return 0;
}
