#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, Q;
  cin >> N >> Q;
  string S;
  cin >> S;
  long long i, j, k;
  vector<char> T;
  vector<char> D;
  for (i = 0; i < Q; i++) {
    char t, d;
    cin >> t >> d;
    T.push_back(t);
    D.push_back(d);
  }
  reverse(T.begin(), T.end());
  reverse(D.begin(), D.end());
  long long L_depth = 0;
  i = 0;
  while (i < Q) {
    if (S.at(L_depth) == T.at(i) && D.at(i) == 'L') {
      L_depth++;
    } else if (L_depth != 0) {
      if (S.at(L_depth - 1) == T.at(i) && D.at(i) == 'R') {
        L_depth--;
        break;
      }
    }
    i++;
  }
  long long R_depth = N - 1;
  i = 0;
  while (i < Q) {
    if (S.at(R_depth) == T.at(i) && D.at(i) == 'R') {
      R_depth--;
    } else if (R_depth != N - 1) {
      if (S.at(R_depth + 1) == T.at(i) && D.at(i) == 'L') {
        R_depth++;
        break;
      }
    }
    i++;
  }
  long long zero = 0;
  if (L_depth > R_depth) {
    cout << 0;
  } else {
    cout << max(R_depth - L_depth + 1, zero);
  }
}
