#include <bits/stdc++.h>
using namespace std;
int biSearchLeft(string s, vector<char> qchar, vector<int> qdir) {
  int left, right, center;
  for (center = s.size() / 2, left = 0, right = s.size(); left < right;
       center = (left + right) / 2) {
    char* pos = &s[center];
    for (int turn = 0; turn < qchar.size(); turn++) {
      if (qchar[turn] == *pos) {
        pos += qdir[turn];
      }
    }
    if (*pos == 'l') {
      left = center + 1;
    } else {
      right = center;
    }
  }
  return center;
}
int biSearchRight(string s, vector<char> qchar, vector<int> qdir) {
  int left, right, center;
  for (center = s.size() / 2, left = 0, right = s.size(); left < right;
       center = (left + right) / 2) {
    char* pos = &s[center];
    for (int turn = 0; turn < qchar.size(); turn++) {
      if (qchar[turn] == *pos) {
        pos += qdir[turn];
      }
    }
    if (*pos == 'r') {
      right = center - 1;
    } else {
      left = center;
    }
  }
  return center;
}
int main(void) {
  int N, Q;
  string s;
  cin >> N >> Q;
  cin >> s;
  vector<char> qchar(Q);
  vector<int> qdir(Q);
  for (int i = 0; i < Q; i++) {
    char d;
    cin >> qchar[i] >> d;
    qdir[i] = (d == 'L') ? -1 : 1;
  }
  s = "l" + s + "r";
  int boderL = biSearchLeft(s, qchar, qdir);
  int boderR = biSearchRight(s, qchar, qdir);
  cout << boderR - boderL + 1 << endl;
  return 0;
}
