#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q;
  cin >> n >> q;
  vector<vector<int> > vt(26);
  for (int i = 0; i < n; i++) {
    char tmp;
    cin >> tmp;
    vt[tmp - 'A'].push_back(i);
  }
  vector<int> ans(n + 2, 1);
  for (int i = 0; i < q; i++) {
    char place, direction;
    cin >> place >> direction;
    for (int j = 0; j < vt[place - 'A'].size(); j++) {
      if (direction == 'L') {
        ans[vt[place - 'A'][j]] += ans[vt[place - 'A'][j] + 1];
        ans[vt[place - 'A'][j] + 1] = 0;
        if (vt[place - 'A'][j] == 0) ans[vt[place - 'A'][j]] = 0;
      } else {
        ans[vt[place - 'A'][j] + 2] += ans[vt[place - 'A'][j] + 1];
        ans[vt[place - 'A'][j] + 1] = 0;
        if (vt[place - 'A'][j] + 2 == n + 1) ans[vt[place - 'A'][j] + 2] = 0;
      }
    }
  }
  int f_ans = 0;
  for (int i = 1; i <= n; i++) {
    f_ans += ans[i];
  }
  cout << f_ans << endl;
  return 0;
}
