#include <bits/stdc++.h>
using namespace std;
typedef struct block {
  int golem_num;
  char word;
} Block;
typedef struct magic {
  string word;
  char LR;
} Magic;
vector<int> find_all(string str, string subStr);
vector<int> find_all(const string str, const string subStr) {
  vector<int> result;
  int subStrSize = (int)subStr.length();
  int pos = (int)str.find(subStr);
  while (pos != std::string::npos) {
    result.push_back(pos);
    pos = (int)str.find(subStr, pos + subStrSize);
  }
  return result;
}
int main() {
  int N, Q;
  string s;
  cin >> N;
  cin >> Q;
  cin >> s;
  Block block[N];
  for (int i = 0; i < N; i++) {
    block[i].golem_num = 1;
    block[i].word = {s[i]};
  }
  Magic magic[Q];
  for (int q = 0; q < Q; q++) {
    cin >> magic[q].word;
    cin >> magic[q].LR;
  }
  for (int q = 0; q < Q; q++) {
    string word = magic[q].word;
    char LR = magic[q].LR;
    vector<int> word_q = find_all(s, word);
    if (LR == 'L') {
      for (int i : word_q) {
        if (i == 0) {
          block[i].golem_num = 0;
        } else {
          block[i - 1].golem_num += block[i].golem_num;
          block[i].golem_num = 0;
        }
      }
    } else {
      reverse(word_q.begin(), word_q.end());
      for (int i : word_q) {
        if (i == N - 1) {
          block[i].golem_num = 0;
        } else {
          block[i + 1].golem_num += block[i].golem_num;
          block[i].golem_num = 0;
        }
      }
    }
  }
  int sum = 0;
  for (int i = 0; i < N; i++) {
    sum += block[i].golem_num;
  }
  cout << sum << endl;
  return 0;
}
