#include <bits/stdc++.h>
int n, q;
char s[300000] = {};
int t[300000] = {};
int d[300000] = {};
int kekka(int x) {
  int iti = x;
  int mode = 0;
  for (int i = 0; i < q; i++) {
    if (s[iti] == t[i]) {
      if (d[i] == 0)
        iti--;
      else
        iti++;
    }
    if (iti == -1) {
      mode = -1;
      break;
    }
    if (iti == n) {
      mode = 1;
      break;
    }
  }
  return mode;
}
int main() {
  scanf("%d%d", &n, &q);
  scanf("%s", s);
  char x[2];
  char y[2];
  for (int i = 0; i < q; i++) {
    scanf("%s%s", x, y);
    t[i] = x[0];
    d[i] = (y[0] == 'R');
  }
  int ll, rr;
  int l = 0;
  int r = n - 1;
  if (kekka(0) >= 0) {
    ll = -1;
  } else {
    for (int i = 0; true; i++) {
      if (l + 1 == r) {
        ll = l;
        break;
      }
      if (kekka((l + r) / 2) == -1)
        l = (l + r) / 2;
      else
        r = (l + r) / 2;
    }
  }
  l = 0;
  r = n - 1;
  if (kekka(n - 1) <= 0) {
    rr = n;
  } else {
    for (int i = 0; true; i++) {
      if (l + 1 == r) {
        rr = r;
        break;
      }
      if (kekka((l + r) / 2) == 1)
        r = (l + r) / 2;
      else
        l = (l + r) / 2;
    }
  }
  printf("%d\n", rr - ll - 1);
  return 0;
}
