#include <bits/stdc++.h>
using namespace std;
struct node {
  int nowcnt, zencnt;
} s[200010];
vector<int> v[30];
int n, q;
char str[200010];
int main() {
  int id;
  scanf("%d%d", &n, &q);
  scanf("%s", str + 1);
  for (int i = 1; i < 30; i++) v[i].clear();
  for (int i = 1; i <= n; i++) {
    s[i].nowcnt = 1, s[i].zencnt = 0;
    id = str[i] - 'A' + 1;
    v[id].push_back(i);
  }
  char c, op;
  getchar();
  for (int i = 1; i <= q; i++) {
    scanf("%c %c", &c, &op);
    getchar();
    id = c - 'A' + 1;
    for (int i = 0; i < v[id].size(); i++) {
      int k = v[id][i];
      if (op == 'L') s[k - 1].zencnt += s[k].nowcnt, s[k].nowcnt = 0;
      if (op == 'R') s[k + 1].zencnt += s[k].nowcnt, s[k].nowcnt = 0;
    }
    for (int i = 0; i < v[id].size(); i++) {
      int k = v[id][i];
      if (op == 'L')
        s[k - 1].nowcnt += s[k - 1].zencnt, s[k - 1].zencnt = 0;
      else
        s[k + 1].nowcnt += s[k + 1].zencnt, s[k + 1].zencnt = 0;
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) ans += s[i].nowcnt;
  printf("%d\n", ans);
  return 0;
}
