#include <bits/stdc++.h>
int max(int a, int b) { return (a > b ? a : b); }
int min(int a, int b) { return (a < b ? a : b); }
int compare_int(const void *a, const void *b) { return *(int *)a - *(int *)b; }
double BS(int array[], int len, int target);
int N, Q;
char blank;
char S[200010], t[200010], d[200010];
int mid, g;
int zero1() {
  for (int i = 0; i < Q; i++) {
    if (d[i] == 'L' && t[i] == S[1]) return 1;
  }
  return 0;
}
int nibun1(int n, int M) {
  mid = (M + n + 1) / 2;
  g = mid;
  for (int i = 0; i < Q; i++) {
    if (d[i] == 'R' && t[i] == S[g] && g > 0 && g < N + 1) g++;
    if (d[i] == 'L' && t[i] == S[g] && g > 0 && g < N + 1) g--;
  }
  if (g != 0 && M - n <= 1) return n;
  if (g == 0 && M - n <= 1) return M;
  if (g != 0) return nibun1(n, (mid + M) / 2);
  if (g == 0) return nibun1((n + mid + 1) / 2, M);
}
int zero2() {
  for (int i = 0; i < Q; i++) {
    if (d[i] == 'R' && t[i] == S[N]) return 1;
  }
  return 0;
}
int nibun2(int n, int M) {
  mid = (M + n) / 2;
  g = mid;
  for (int i = 0; i < Q; i++) {
    if (d[i] == 'R' && t[i] == S[g] && g > 0 && g < N + 1) g++;
    if (d[i] == 'L' && t[i] == S[g] && g > 0 && g < N + 1) g--;
  }
  if (g != N + 1 && M - n <= 1) return M;
  if (g == N + 1 && M - n <= 1) return n;
  if (g != N + 1) return nibun2((n + mid + 1) / 2, M);
  if (g == N + 1) return nibun2(n, (mid + M) / 2);
}
int main() {
  scanf("%d%d", &N, &Q);
  scanf("%s", S);
  for (int i = 0; i < Q; i++) {
    scanf("%c%c%c%c", &blank, &t[i], &blank, &d[i]);
  }
  for (int i = N; i > 0; i--) {
    S[i] = S[i - 1];
  }
  int count = N;
  if (zero1()) {
    count -= nibun1(1, N);
  }
  if (zero2()) {
    count -= N - nibun2(1, N) + 1;
  }
  printf("%d\n", count);
  return 0;
}
double BS(int array[], int len, int target) {
  int low, mid, high;
  low = 0;
  high = len - 1;
  int mark;
  while (low <= high) {
    mid = (low + high) / 2;
    if (array[mid] == target) {
      mark = 0;
      break;
    } else if (array[mid] < target) {
      low = mid + 1;
      mark = 1;
    } else {
      high = mid - 1;
      mark = -1;
    }
  }
  if (mark == 0) {
    return mid;
  } else if (mark == 1) {
    return (double)mid + 0.5;
  } else {
    return (double)mid - 0.5;
  }
}
