#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long N, Q;
  string S;
  char t[214514], d[214514];
  cin >> N >> Q;
  cin >> S;
  for (long long i = 0; i < (Q); ++i) {
    cin >> t[i] >> d[i];
  }
  long long l = 0, r = 0;
  for (long long i = Q - 1; i >= 0; --i) {
    if (d[i] == 'L') {
      if (S[l] == t[i]) l++;
    } else {
      if (S[N - 1 - r] == t[i]) r++;
    }
  }
  cout << N - l - r << endl;
  return 0;
}
