#include <bits/stdc++.h>
int checkMove(char *s, char *t, char *d, int n, int q, int b) {
  int i;
  for (i = 0; i < q; ++i) {
    if (s[b] == t[i]) {
      b += ((d[i] == 'R') ? 1 : -1);
      if (b < 0) {
        return -1;
      }
      if (b > n - 1) {
        return 1;
      }
    }
  }
  return 0;
}
int main(void) {
  int n, q, i;
  int dummy;
  scanf("%d %d", &n, &q);
  char s[n];
  scanf("%s", s);
  char t[q], d[q];
  for (i = 0; i < q; ++i) {
    scanf("\n %c %c", &t[i], &d[i]);
  }
  int a = 0, b_prev = -1, c = n - 1;
  int b;
  while (1) {
    b = (a + c) / 2;
    if (b == b_prev) {
      break;
    }
    if (checkMove(s, t, d, n, q, b) < 0) {
      a = b;
    } else {
      c = b;
    }
    b_prev = b;
  }
  int left = a;
  a = 0;
  b_prev = -1;
  c = n - 1;
  while (1) {
    b = (a + c + 1) / 2;
    if (b == b_prev) {
      break;
    }
    if (checkMove(s, t, d, n, q, b) > 0) {
      c = b;
    } else {
      a = b;
    }
    b_prev = b;
  }
  int right = c;
  if (left == 0) {
    if (checkMove(s, t, d, n, q, 0) < 0) {
      printf("%d\n", right - left - 1);
    } else {
      printf("%d\n", right - left);
    }
  } else {
    printf("%d\n", right - left - 1);
  }
  return 0;
}
