#include <bits/stdc++.h>
int main(void) {
  int N, Q;
  int g[200000];
  char s[200000];
  char t, d;
  int tmp[2] = {};
  scanf("%d %d", &N, &Q);
  for (int i = 0; i < N; i++) {
    scanf("%c", &s[i]);
    g[i] = 1;
  }
  for (int i = 0; i < Q; i++) {
    scanf("%c %c", &t, &d);
  }
  int count = 0;
  for (int i = 0; i < Q; i++) {
    if (d == 'L') {
      for (int j = 0; j < N; j++) {
        if (t == s[j]) {
          if (j == 0) {
            g[j] = 0;
          } else {
            g[j - 1] += g[j];
            g[j] = 0;
          }
        }
      }
    } else {
      for (int j = N - 1; j > -1; j--) {
        if (t == s[j]) {
          if (j == N - 1) {
            g[j] = 0;
          } else {
            g[j + 1] += g[j];
            g[j] = 0;
          }
        }
      }
    }
  }
  for (int i = 0; i < N; i++) {
    count += g[i];
  }
  printf("%d", count);
  return 0;
}
