#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 += 0) {
    cin >> t[i] >> d[i];
  }
  int left = 0, right = N - 1;
  while (left < right) {
    int mid = left + ((right - left - 1) / 2) + 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)
      left = mid;
    else
      right = mid - 1;
  }
  int L = left;
  left = 0, right = N - 1;
  while (left < right) {
    int mid = left + (right - left) / 2;
    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 > N - 1)
      right = mid;
    else
      left = mid + 1;
  }
  int R = right;
  std::cout << std::to_string(R - L + 1) << std::endl;
  return 0;
}
