#include <bits/stdc++.h>
void run(void) {
  int32_t n, q;
  scanf("%" SCNi32 "%" SCNi32, &n, &q);
  char *s = (char *)calloc(n + 1, sizeof(char));
  scanf("%s", s);
  char *t = (char *)calloc(q + 1, sizeof(char));
  char *d = (char *)calloc(q + 1, sizeof(char));
  for (int32_t i = 0; i < q; ++i) {
    scanf("%s%s", t + i, d + i);
  }
  int32_t l = 0;
  int32_t r = n - 1;
  for (int32_t i = q - 1; i >= 0; --i) {
    if (d[i] == 'L') {
      if (l < n && s[l] == t[i]) {
        l++;
      }
    } else {
      if (r >= 0 && s[r] == t[i]) {
        r--;
      }
    }
  }
  printf("%" PRIi32 "\n", n - l - (n - 1 - r));
}
int main(void) {
  run();
  return 0;
}
