#include <bits/stdc++.h>
int main() {
  int N, Q;
  std::string s;
  std::vector<std::pair<char, char>> td;
  std::unordered_set<int> fallpos;
  std::cin >> N >> Q;
  std::cin >> s;
  for (int i = 0; i < Q; ++i) {
    std::string t, d;
    std::cin >> t >> d;
    td.push_back({t[0], d[0]});
  }
  for (int q = Q - 1; q >= 0; --q) {
    std::unordered_set<int> nextfallpos;
    char t = td[q].first;
    char d = td[q].second;
    if (d == 'L') {
      for (auto pos : fallpos) {
        if (s[pos] != t) nextfallpos.insert(pos);
        if (pos < N - 1 && s[pos + 1] == t) nextfallpos.insert(pos + 1);
      }
      if (s[0] == t) nextfallpos.insert(0);
    } else {
      for (auto pos : fallpos) {
        if (s[pos] != t) nextfallpos.insert(pos);
        if (pos > 0 && s[pos - 1] == t) nextfallpos.insert(pos - 1);
      }
      if (s[N - 1] == t) nextfallpos.insert(N - 1);
    }
    fallpos = std::move(nextfallpos);
  }
  std::cout << (N - fallpos.size()) << "\n";
}
