#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, Q;
  cin >> N >> Q;
  string S;
  cin >> S;
  vector<char> T(Q + 1), D(Q + 1);
  for (int i = 0; i < (Q); i++) cin >> T[i] >> D[i];
  int j = 0, k = 0, f = 1000000, g = 1000000;
  for (int i = 0; i < (Q); i++) {
    if (j)
      if (T[Q - 1 - i] == S[j - 1] && D[Q - 1 - i] == 'R')
        f = max(f, j - 1), j = 0;
    if (T[Q - 1 - i] == S[j] && D[Q - 1 - i] == 'L') j++;
    if (k)
      if (T[Q - 1 - i] == S[N - 1 - k + 1] && D[Q - 1 - i] == 'L')
        g = max(g, k - 1), k = 0;
    if (T[Q - 1 - i] == S[N - 1 - k] && D[Q - 1 - i] == 'R') k++;
  }
  cout << max(0, N - min(j, f) - min(k, g)) << endl;
}
