#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];
  }
  vector<int> pr(n + 2, 1);
  for (int i = 0; i < q; ++i) {
    auto pr2 = pr;
    for (int j = 1; j < n + 1; ++j) {
      if (s[j - 1] != t[i]) continue;
      if (pr[j] == 0) continue;
      if (d[i] == 'L') {
        pr2[j - 1] += pr[j];
      } else {
        pr2[j + 1] += pr[j];
      }
      pr2[j] -= pr[j];
    }
    pr = pr2;
  }
  int ret = 0;
  for (int j = 1; j < n + 1; ++j) {
    ret += pr[j];
  }
  cout << ret << endl;
}
