#include <bits/stdc++.h>
int main(void) {
  int N, Q;
  scanf("%d %d", &N, &Q);
  char s[200001];
  scanf("%s", s);
  char t[200001];
  char d[200001];
  for (int i = 0; i < Q; i++) {
    scanf(" %c %c", &t[i], &d[i]);
  }
  char g[200001];
  memset(g, 1, 200001);
  for (int i = 0; i < Q; i++) {
    if (d[i] == 'L') {
      for (int j = 0; j < N; j++) {
        if (t[i] != s[j]) continue;
        if (j != 0) {
          g[j - 1] += g[j];
        }
        g[j] = 0;
      }
    } else {
      for (int j = N - 1; j >= 0; j--) {
        if (t[i] != s[j]) continue;
        if (j != (N - 1)) {
          g[j + 1] += g[j];
        }
        g[j] = 0;
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (g[i] != 0) ans += g[i];
  }
  printf("%d\n", ans);
  return 0;
}
