#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int n, Q, cnt[N];
vector<int> pos[26];
char s[N];
int main() {
  int i;
  char t[2], d[2];
  while (scanf("%d%d", &n, &Q) != EOF) {
    cnt[0] = cnt[n + 1] = 0;
    for (i = 1; i <= n; i++) cnt[i] = 1;
    for (i = 0; i < 26; i++) pos[i].clear();
    scanf("%s", s + 1);
    for (i = 1; i <= n; i++) pos[s[i] - 'A'].push_back(i);
    for (i = 1; i <= Q; i++) {
      scanf("%s%s", t, d);
      vector<int>::iterator it;
      for (it = pos[t[0] - 'A'].begin(); it != pos[t[0] - 'A'].end(); it++) {
        if (d[0] == 'L')
          cnt[(*it) - 1] += cnt[*it], cnt[*it] = 0;
        else
          cnt[(*it) + 1] += cnt[*it], cnt[*it] = 0;
      }
    }
    printf("%d\n", n - cnt[0] - cnt[n + 1]);
  }
  return 0;
}
