#include <bits/stdc++.h>
int main() {
  long long int N, Q;
  std::cin >> N >> Q;
  std::vector<long long int> golem, golem_temp;
  std::vector<char> block;
  std::string s;
  struct Spell {
    char t;
    char d;
  };
  std::vector<Spell> spells;
  golem.resize(N);
  golem_temp.resize(N);
  block.resize(N);
  spells.resize(Q);
  std::cin >> s;
  for (auto& it : spells) {
    std::cin >> it.t >> it.d;
  }
  for (int i = 0; i < N; ++i) {
    golem[i] = i;
    block[i] = s[i];
  }
  for (auto spell : spells) {
    golem_temp = golem;
    for (int i = 0; i < N; ++i) {
      if (block[i] == spell.t) {
        for (int j = 0; j < golem.size(); ++j) {
          if (golem[j] == i) {
            if (spell.d == 'L') {
              --golem_temp[j];
            } else {
              ++golem_temp[j];
            }
            if (golem_temp[j] < 0 || N <= golem_temp[j]) {
              golem_temp.erase(golem_temp.begin() + j);
            }
          }
        }
      }
    }
    golem = golem_temp;
    golem_temp.clear();
  }
  long long int count;
  count = 0;
  for (auto it : golem) {
    if (0 <= it && it < N) ++count;
  }
  std::cout << count << std::endl;
  return 0;
}
