#include <bits/stdc++.h>
using namespace std;
struct Data {
  char t, d;
};
int main() {
  long long N, Q;
  cin >> N >> Q;
  string S;
  cin >> S;
  vector<int> isOuts(N, 0);
  vector<Data> qs(Q);
  for (long long i = 0; i < (Q); ++i) {
    cin >> qs[i].t >> qs[i].d;
  }
  int left = 0;
  int right = N - 1;
  for (long long ri = 0; ri < (Q); ++ri) {
    int i = Q - 1 - ri;
    if (S[left] == qs[i].t) {
      if (qs[i].d == 'L') {
        left++;
      }
    }
    if (S[right] == qs[i].t) {
      if (qs[i].d == 'R') {
        right--;
      }
    }
  }
  int total = right - left + 1;
  if (total < 0) {
    total = 0;
  }
  cout << total << endl;
  return 0;
}
