#include <bits/stdc++.h>
using namespace std;
int main(void) {
  ios::sync_with_stdio(false);
  int N, Q;
  cin >> N >> Q;
  string S;
  cin >> S;
  vector<char> T(Q);
  vector<char> D(Q);
  for (int i = 0; i < (Q); i++) {
    cin >> T[i] >> D[i];
  }
  int left = 0;
  int right = min(Q, N - 1);
  while (left < right) {
    int mid = left + (right - left) / 2;
    int pos = mid;
    bool out = false;
    for (int i = 0; i < (Q); i++) {
      if (S[pos] == T[i]) {
        pos += (D[i] == 'L') ? -1 : +1;
      }
      if (pos < 0) {
        out = true;
        break;
      }
    }
    if (out) {
      left = mid + 1;
    } else {
      right = mid;
    }
  }
  int answer = N - left;
  left = N - min(Q, N);
  right = N - 1;
  while (left + 1 < right) {
    int mid = left + (right - left) / 2;
    int pos = mid;
    bool out = false;
    for (int i = 0; i < (Q); i++) {
      if (S[pos] == T[i]) {
        pos += (D[i] == 'L') ? -1 : +1;
      }
      if (N <= pos) {
        out = true;
        break;
      }
    }
    if (out) {
      right = mid;
    } else {
      left = mid;
    }
  }
  answer -= (N - left - 1);
  cout << answer << endl;
  return 0;
}
