#include <bits/stdc++.h>
int main() {
  long long n, q;
  std::cin >> n >> q;
  std::string s;
  std::vector<int> tnum(n + 2, 1);
  std::vector<std::vector<int> > vecmap;
  std::map<char, int> cmap;
  std::cin >> s;
  for (int i = 0; i < n; i++) {
    if (cmap.find(s[i]) == cmap.end()) {
      cmap.insert(std::make_pair(s[i], i));
      std::vector<int> tmpvec(1, i + 1);
      vecmap.push_back(tmpvec);
    } else {
      vecmap[cmap[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;
    int vecnum = cmap[t];
    for (int j = 0; j < vecmap[vecnum].size(); j++) {
      if (tnum[vecmap[vecnum][j]] != 0) {
        tnum[vecmap[vecnum][j] + dnum] += tnum[vecmap[vecnum][j]];
        tnum[vecmap[vecnum][j]] = 0;
      }
    }
  }
  long long answer = 0;
  for (int i = 1; i <= n; i++) {
    answer += tnum[i];
  }
  std::cout << answer << std::endl;
  return 0;
}
