#include <bits/stdc++.h>
using namespace std;
int main() {
  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 += 1) {
    cin >> t[i] >> d[i];
  }
  int L = -1;
  int left = 0, right = N - 1;
  while (left < right) {
    int mid = (left + right) >> 1;
    int inx = mid;
    for (int i = 0; i < Q; i += 1) {
      if (s[inx] == t[i]) {
        if (d[i] == 'L')
          inx -= 1;
        else
          inx += 1;
      }
      if (inx < 0 || inx > N - 1) break;
    }
    if (inx < 0) {
      L = mid;
      left = mid + 1;
    } else
      right = mid - 1;
  }
  int R = N;
  left = 0, right = N - 1;
  while (left < right) {
    int mid = (left + right) >> 1;
    int inx = mid;
    for (int i = 0; i < Q; i += 1) {
      if (s[inx] == t[i]) {
        if (d[i] == 'R')
          inx += 1;
        else
          inx -= 1;
      }
      if (inx < 0 || inx > N - 1) break;
    }
    if (inx > N - 1) {
      R = mid;
      right = mid - 1;
    } else
      left = mid + 1;
  }
  std::cout << std::to_string(R - L - 1) << std::endl;
  return 0;
}
