#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, q;
  string s;
  cin >> n >> q;
  cin >> s;
  vector<int> gorem(200010, 1);
  vector<int> vs[26];
  for (int i = 0; i < n; i++) {
    vs[s[i] - 'A'].push_back(i);
  }
  for (int i = 0; i < q; i++) {
    char t, d;
    cin >> t >> d;
    int nextPos = 0;
    if (d == 'L') {
      nextPos = -1;
    } else {
      nextPos = 1;
    }
    for (int j = 0; j < vs[t - 'A'].size(); j++) {
      if (vs[t - 'A'][j] + nextPos >= n || vs[t - 'A'][j] + nextPos < 0) {
        gorem[vs[t - 'A'][j]] = 0;
      } else {
        gorem[vs[t - 'A'][j] + nextPos] += gorem[vs[t - 'A'][j]];
        gorem[vs[t - 'A'][j]] = 0;
      }
    }
  }
  int sum = 0;
  for (int i = 0; i < n; i++) {
    sum += gorem[i];
  }
  printf("%d\n", sum);
  return 0;
}
