#include <bits/stdc++.h>
int main() {
  int i, j;
  int total = 0;
  int n = 0;
  int q = 0;
  int grm[2000];
  char t[256];
  char d[256];
  int grm_d = 0;
  char s[256];
  scanf("%d %d", &n, &q);
  total = n;
  scanf("%s", &s);
  for (j = 0; j < q; j++) {
    scanf("%c %c", &t[j], &d[j]);
  }
  j = 0;
  for (i = 0; i < n; i++) {
    if ((i == 0 && d[i] == 'L') || (i == n - 1 && d[i] == 'R')) {
      grm_d = grm[i];
      grm[i] = 0;
    } else if (s[i] == t[j] && d[i] == 'L') {
      grm[i - 1] += grm[i];
    } else {
      grm[i + 1] += grm[i];
    }
    j++;
  }
  total -= grm_d;
  printf("%d", total);
  return 0;
}
