#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, Q;
  cin >> N >> Q;
  vector<char> S(N);
  for (int i = 0; i < N; i++) {
    cin >> S[i];
  }
  vector<char> T(Q), D(Q);
  for (int i = 0; i < Q; i++) {
    cin >> T[i] >> D[i];
  }
  int Lidx = 0, Ridx = N - 1;
  for (int i = Q - 1; i >= 0; i--) {
    if (T[i] == S[Lidx] and D[i] == 'L') {
      Lidx = min(N - 1, Lidx + 1);
    }
    if (T[i] == S[Lidx - 1] and D[i] == 'R') {
      Lidx = max(0, Lidx - 1);
    }
    if (T[i] == S[Ridx] and D[i] == 'R') {
      Ridx = max(0, Ridx - 1);
    }
    if (T[i] == S[Ridx + 1] and D[i] == 'L') {
      Ridx = min(N - 1, Ridx + 1);
    }
  }
  int ans;
  if (Lidx > Ridx) {
    ans = 0;
  } else {
    ans = Ridx - Lidx + 1;
  }
  cout << ans << endl;
  return 0;
}
