#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
vector<int> G[50];
int cnt[maxn];
char s[maxn];
int main() {
  int n, q;
  scanf("%d%d%s", &n, &q, s);
  for (int i = 0; i < n; i++) {
    int x = s[i] - 'A';
    G[x].push_back(i);
    cnt[i] = 1;
  }
  while (q--) {
    char str[3], dir[3];
    scanf("%s%s", str, dir);
    int x = str[0] - 'A';
    for (int i = 0, sz = G[x].size(); i < sz; i++) {
      int indx = G[x][i];
      if (cnt[indx] == 0) continue;
      if (indx == 0 && dir[0] == 'L') {
        cnt[0] = 0;
      } else if (indx == n - 1 && dir[0] == 'R') {
        cnt[indx] = 0;
      } else {
        int delt = dir[0] == 'L' ? -1 : 1;
        cnt[indx + delt] += cnt[indx];
        cnt[indx] = 0;
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) ans += cnt[i];
  printf("%d\n", ans);
  return 0;
}
