#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, Q;
  cin >> N >> Q;
  vector<int> v(N, 1);
  vector<vector<int> > x('Z' - 'A' + 1);
  string s;
  cin >> s;
  for (int j = 0; j < s.size(); ++j) {
    x[s[j] - 'A'].push_back(j);
  }
  for (int i = 0; i < Q; ++i) {
    char t, d;
    cin >> t >> d;
    vector<pair<int, int> > vp;
    for (int j : x[t - 'A']) {
      if (d == 'L') {
        if (j != 0) vp.push_back(make_pair(j - 1, v[j]));
      } else {
        if (j != N - 1) vp.push_back(make_pair(j + 1, v[j]));
      }
      v[j] = 0;
    }
    for (auto p : vp) {
      v[p.first] += p.second;
    }
  }
  int total = 0;
  for (int i = 0; i < N; ++i) {
    total += v[i];
  }
  cout << total << endl;
  return 0;
}
