#include <bits/stdc++.h>
int main(void) {
  int N, Q, Sc[200001];
  char s[200001], Zyumon[2][200001];
  int Count, C, M;
  scanf("%d %d", &N, &Q);
  scanf("%s", &s);
  for (Count = 0; Count < Q; Count++) {
    scanf("%s %s", &Zyumon[0][Count], &Zyumon[1][Count]);
  }
  for (Count = 0; Count < N; Count++) {
    Sc[Count] = 1;
  }
  for (Count = 0; Count < Q; Count++) {
    for (C = 0; C < N; C++) {
      if (Zyumon[0][Count] == s[C]) {
        if (Zyumon[1][Count] == 'L') {
          if (C == 0) {
            Sc[0] = 0;
          } else {
            Sc[C - 1] += Sc[C];
            Sc[C] = 0;
          }
        } else if (Zyumon[1][Count] == 'R') {
          if (C == N - 1) {
            Sc[N - 1] = 0;
          } else {
            Sc[C + 1] += Sc[C];
            Sc[C] = 0;
          }
        }
      }
    }
  }
  C = 0;
  for (Count = 0; Count < N; Count++) {
    C += Sc[Count];
  }
  printf("%d", C);
  return 0;
}
