#include <bits/stdc++.h>
struct Spell {
  char t;
  char d;
};
int solve(const std::string& board, const std::vector<Spell>& spells) {
  std::vector<int> golems(board.size(), 1);
  for (const auto& s : spells) {
    const auto index_delta = s.d == 'L' ? -1 : 1;
    std::vector<int> golem_deltas(golems.size(), 0);
    const auto n = static_cast<int>(board.size());
    for (int i = 0; i < n; ++i) {
      if (board[i] != s.t) continue;
      int j = i + index_delta;
      if (j >= 0 && j < n) {
        golem_deltas[j] = golems[i];
      }
      golems[i] = 0;
    }
    for (int i = 0; i < n; ++i) {
      golems[i] += golem_deltas[i];
    }
  }
  return std::accumulate(golems.begin(), golems.end(), 0);
}
int main() {
  int n, q;
  std::string s;
  std::cin >> n >> q >> s;
  std::vector<Spell> spells(q);
  for (int i = 0; i < q; ++i) {
    std::cin >> spells[i].t >> spells[i].d;
  }
  std::cout << solve(s, spells) << std::endl;
}
