#include <bits/stdc++.h>
int main() {
  int N, Q;
  std::string s;
  std::vector<std::pair<char, char>> td;
  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]});
  }
  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') {
      if (s[0] == t) {
        golems -= cells[0];
        cells[0] = 0;
      }
      for (int i = 1; i < N; ++i) {
        if (s[i] == t) {
          cells[i - 1] += cells[i];
          cells[i] = 0;
        }
      }
    } else {
      if (s[N - 1] == t) {
        golems -= cells[N - 1];
        cells[N - 1] = 0;
      }
      for (int i = N - 2; i >= 0; --i) {
        if (s[i] == t) {
          cells[i + 1] += cells[i];
          cells[i] = 0;
        }
      }
    }
  }
  std::cout << golems << "\n";
}
