#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200000 + 10;
int n, q;
int query[MAXN][2];
char input[MAXN];
inline bool check(int x) {
  for (register int i = 1; i <= q; i++) {
    if (query[i][0] == input[x] - 'A') {
      x += query[i][1];
      if (x <= 0) return true;
    }
  }
  return false;
}
inline bool check2(int x) {
  for (register int i = 1; i <= q; i++) {
    if (query[i][0] == input[x] - 'A') {
      x += query[i][1];
      if (x > n) return true;
    }
  }
  return false;
}
int main() {
  scanf("%d%d", &n, &q);
  scanf("%s", input + 1);
  for (register int i = 1; i <= q; i++) {
    char A, B;
    scanf(" %c %c", &A, &B);
    query[i][0] = A - 'A';
    query[i][1] = (B == 'L' ? -1 : 1);
  }
  int lL = 1, lR = n;
  int rL = 1, rR = n;
  while (lL < lR) {
    int mid = (lL + lR) >> 1;
    if (check(mid)) {
      lL = mid + 1;
    } else {
      lR = mid;
    }
  }
  while (rL < rR) {
    int mid = ((rL + rR) >> 1) + 1;
    if (check2(mid)) {
      rR = mid - 1;
    } else {
      rL = mid;
    }
  }
  printf("%d\n", (rL - lL + 1));
  return 0;
}
