#include <bits/stdc++.h>
int main() {
  int N, Q;
  std::string s;
  std::vector<std::pair<char, char>> td;
  std::unordered_map<char, std::vector<int>> poss;
  std::vector<int> cells;
  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 i = 0; i < N; ++i) {
    poss[s[i]].push_back(i);
  }
  cells.resize(N);
  for (auto& n : cells) n = 1;
  int golems = N;
  for (int q = 0; q < Q; ++q) {
    char t = td[q].first;
    char d = td[q].second;
    if (d == 'L') {
      const auto& tposs = poss[t];
      for (auto it = tposs.begin(), end = tposs.end(); it != end; ++it) {
        auto pos = *it;
        if (pos == 0) {
          golems -= cells[pos];
          cells[pos] = 0;
        } else {
          cells[pos - 1] += cells[pos];
          cells[pos] = 0;
        }
      }
    } else {
      const auto& tposs = poss[t];
      for (auto it = tposs.rbegin(), end = tposs.rend(); it != end; ++it) {
        auto pos = *it;
        if (pos == N - 1) {
          golems -= cells[pos];
          cells[pos] = 0;
        } else {
          cells[pos + 1] += cells[pos];
          cells[pos] = 0;
        }
      }
    }
  }
  std::cout << golems << "\n";
}
