#include <bits/stdc++.h>
char strs[200001];
char spells[200000];
int LRs[200000];
int main() {
  int N, Q, i, min = -1, max;
  char spell, LR;
  scanf("%d %d\n", &N, &Q);
  max = N;
  scanf("%s\n", strs);
  for (i = 0; i < Q; i++) {
    scanf("%c %c\n", &spell, &LR);
    spells[i] = spell;
    LRs[i] = (LR == 'L' ? 1 : 0);
  }
  for (i = Q - 1; i >= 0; i--) {
    if (LRs[i] == 1 && spells[i] == strs[min + 1]) {
      min++;
    } else if (LRs[i] == 0 && spells[i] == strs[max - 1]) {
      max--;
    }
  }
  printf("%d\n", ((0) > (max - min - 1) ? (0) : (max - min - 1)));
  return 0;
}
