#include <bits/stdc++.h>
int JUDGE_LEFT(int Q, char T[][2], char D[][2], char S[], int x);
int JUDGE_RIGHT(int Q, int N, char T[][2], char D[][2], char S[], int x);
int main(void) {
  int N, Q;
  scanf("%d%d", &N, &Q);
  char S[N];
  char T[Q][2];
  char D[Q][2];
  scanf("%s", S);
  int i, j;
  for (i = 0; i < Q; i++) {
    scanf("%s", T[i]);
    scanf("%s", D[i]);
  }
  int l = 0;
  int r = N - 1;
  int mid;
  int out;
  int temp_l = 0;
  while (l < r) {
    mid = l + (r - l) / 2;
    out = JUDGE_LEFT(Q, T, D, S, mid);
    if (out > 0) {
      temp_l = out;
      l = mid + 1;
    } else {
      r = mid;
    }
  }
  int temp_r = 0;
  l = 0;
  r = N - 1;
  while (r - l > 1) {
    mid = l + (r - l) / 2;
    out = JUDGE_RIGHT(Q, N, T, D, S, mid);
    if (out > 0) {
      temp_r = N - out + 1;
      r = mid;
    } else {
      l = mid;
    }
  }
  printf("%d\n", N - temp_l - temp_r);
  return 0;
}
int JUDGE_LEFT(int Q, char T[][2], char D[][2], char S[], int x) {
  int i;
  int x_out = x;
  for (i = 0; i < Q; i++) {
    if (T[i][0] == S[x_out] && D[i][0] == 'L') {
      x_out = x_out - 1;
    }
    if (x_out == -1) {
      return x + 1;
    }
  }
  return 0;
}
int JUDGE_RIGHT(int Q, int N, char T[][2], char D[][2], char S[], int x) {
  int i;
  int x_out = x;
  for (i = 0; i < Q; i++) {
    if (T[i][0] == S[x_out] && D[i][0] == 'R') {
      x_out = x_out + 1;
    }
    if (x_out == N) {
      return x + 1;
    }
  }
  return 0;
}
