#include <bits/stdc++.h>
int main() {
  long long n, q;
  std::cin >> n >> q;
  std::string s;
  std::cin >> s;
  std::vector<int> tnum(n + 2, 1);
  std::map<char, std::vector<int> > charmap;
  for (int i = 0; i < n; i++) {
    if (charmap.find(s[i]) == charmap.end()) {
      std::vector<int> tmpx;
      tmpx.push_back(i + 1);
      charmap.insert(std::make_pair(s[i], tmpx));
    } else {
      charmap[s[i]].push_back(i + 1);
    }
  }
  for (int i = 0; i < q; i++) {
    char t, d;
    std::cin >> t >> d;
    int dnum = 0;
    if (d == 'L')
      dnum = -1;
    else
      dnum = 1;
    for (int j = 0; j < charmap[t].size(); j++) {
      tnum[charmap[t][j] + dnum] += tnum[charmap[t][j]];
      tnum[charmap[t][j]] = 0;
    }
  }
  long long answer = 0;
  for (int i = 1; i <= n; i++) {
    answer += tnum[i];
  }
  std::cout << answer << std::endl;
  return 0;
}
