#include <bits/stdc++.h>
using namespace std;
int main(int argc, char *argv[]) {
  int N, Q;
  char cs[(200000) + 1], ts[(200000)], ds[(200000)], buf[(30)];
  scanf("%d %d", &N, &Q);
  fgets(buf, (30), stdin);
  scanf("%s", cs);
  fgets(buf, (30), stdin);
  for (int q = 0; q < Q; q++) {
    ts[q] = fgetc(stdin);
    fgetc(stdin);
    ds[q] = fgetc(stdin);
    fgets(buf, (30), stdin);
  }
  int l = -1, r = N;
  for (int q = Q - 1; q >= 0; q--) {
    const char t = ts[q], d = ds[q];
    if (cs[l + 1] == t && d == 'L') {
      l++;
    }
    if (cs[r - 1] == t && d == 'R') {
      r--;
    }
    if (l + 1 >= r) {
      break;
    }
  }
  printf("%d\n", max(r - l - 1, 0));
  return 0;
}
