#include <bits/stdc++.h>
using namespace std;
int n, q, ans;
char s[200000 + 10];
int to[200000 + 10], nxt[30], num[200000 + 10];
int main() {
  scanf("%d%d", &n, &q);
  scanf("%s", s + 1);
  for (int i = n; i >= 1; i--) {
    if (!nxt[s[i] - 'a'])
      to[i] = n + 1;
    else
      to[i] = nxt[s[i] - 'a'];
    nxt[s[i] - 'a'] = i;
    num[i] = 1;
  }
  for (int i = 1; i <= q; i++) {
    int op;
    char str1[30], str2[3];
    scanf("%s%s", str1 + 1, str2 + 1);
    if (str2[1] == 'L')
      op = -1;
    else
      op = 1;
    if (nxt[str1[1] - 'a'] == 0) continue;
    for (int j = nxt[str1[1] - 'a']; j <= n; j = to[j])
      num[j + op] += num[j], num[j] = 0;
  }
  for (int i = 1; i <= n; i++) ans += num[i];
  printf("%d\n", ans);
}
