#include <bits/stdc++.h>
using namespace std;
int main() {
  long N, Q;
  string s;
  map<unsigned char, vector<long>> m;
  cin >> N >> Q >> s;
  for (int n = 0; n < N; n++) m[s[n]].push_back(n);
  vector<long> r(N);
  fill(r.begin(), r.end(), 1);
  for (int q = 0; q < Q; q++) {
    unsigned char t, d;
    cin >> t >> d;
    for (auto const i : m[t]) {
      if (d == 'L' && i > 0) {
        r[i - 1] += r[i];
      } else if (d == 'R' && i < N - 1) {
        r[i + 1] += r[i];
      }
      r[i] = 0;
    }
  }
  long res = 0;
  for (int n = 0; n < N; n++) res += r[n];
  cout << res << endl;
  return 0;
}
