#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q;
  string s;
  cin >> n >> q >> s;
  vector<char> t(q), d(q);
  for (int i = 0; i < q; ++i) {
    cin >> t[i] >> d[i];
  }
  unordered_map<char, vector<int> > tg;
  for (auto ch : s) {
    vector<int> a;
    tg[ch] = a;
  }
  for (int i = 0; i < n; ++i) {
    tg[s[i]].push_back(i + 1);
  }
  vector<int> pr(n + 2, 1);
  for (int i = 0; i < q; ++i) {
    if (tg.count(t[i]) == 0) continue;
    char mv = d[i];
    auto tv = tg[t[i]];
    auto pr2 = pr;
    for (auto it = tv.begin(); it != tv.end(); ++it) {
      if (mv == 'L') {
        pr2[(*it) - 1] += pr[*it];
      } else {
        pr2[(*it) + 1] += pr[*it];
      }
      pr2[(*it)] -= pr[*it];
    }
    pr = pr2;
  }
  int ret = 0;
  for (int i = 1; i < n + 1; ++i) {
    ret += pr[i];
  }
  cout << ret << endl;
  return 0;
}
