#include <bits/stdc++.h>
int qwq[26][10005] = {}, tot[26] = {}, e[10005], book[10005] = {};
int main() {
  int n, m;
  char x;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    e[i] = 1;
  }
  for (int i = 1; i <= n; i++) {
    std::cin >> x;
    qwq[x - 65][++tot[x - 65]] = i;
  }
  char t, q;
  for (int i = 1; i <= m; i++) {
    std::cin >> t >> q;
    if (q == 'L') {
      for (int j = 1; j <= tot[t - 65]; j++) {
        book[qwq[t - 65][j] - 1] += e[qwq[t - 65][j]];
        e[qwq[t - 65][j]] = 0;
      }
    } else
      for (int j = 1; j <= tot[t - 65]; j++) {
        book[qwq[t - 65][j] + 1] += e[qwq[t - 65][j]];
        e[qwq[t - 65][j]] = 0;
      }
    for (int j = 1; j <= n; j++) {
      e[j] += book[j];
      book[j] = 0;
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += e[i];
  }
  printf("%d", ans);
  return 0;
}
