#include <bits/stdc++.h>
void fill(int vc[], int no, int x) {
  int i;
  for (i = 0; i < no; i++) vc[i] = x;
}
int main(void) {
  int N, Q;
  scanf("%d %d", &N, &Q);
  int count = 0, total = 0;
  int sum[N + 2];
  fill(sum, N + 2, 1);
  char s[N + 2], t[Q], d[Q];
  scanf("%s", s);
  for (int i = 0; i < Q; i++) {
    scanf("%s %s", &t[i], &d[i]);
    count = 0;
    for (int j = 1; j <= N; j++) {
      count = count + 1;
      if (t[i] == s[j - 1]) {
        if (d[i] == 'L') {
          sum[count - 1] = sum[count - 1] + sum[count];
          sum[count] = 0;
        } else if (d[i] == 'R') {
          sum[count + 1] = sum[count + 1] + sum[count];
          sum[count] = 0;
        }
      }
    }
  }
  for (int i = 1; i <= N; i++) {
    total = total + sum[i];
  }
  printf("%d \n", total);
  return 0;
}
