#include <bits/stdc++.h>
int diff[4][2] = {
    {0, -1},
    {-1, 0},
    {1, 0},
    {0, 1},
};
char s[200001];
int pos[26][200000];
int cntC[26];
int cnt[200000];
int Min(int a, int b) { return (a) < (b) ? (a) : (b); }
int Max(int a, int b) { return (a) > (b) ? (a) : (b); }
long long Minl(long long a, long long b) { return (a) < (b) ? (a) : (b); }
void Swap(int *a, int *b) {
  int tmp = *a;
  *a = *b;
  *b = tmp;
}
int main() {
  int n, q;
  scanf("%d%d", &n, &q);
  scanf("%s", s);
  for (int i = 0, i_len = (int)(strlen(s)); i < i_len; i++) {
    cnt[i] = 1;
  }
  for (int i = 0, i_len = (int)(strlen(s)); i < i_len; i++) {
    int c = s[i] - 'A';
    pos[c][cntC[c]] = i;
    cntC[c]++;
  }
  char t[200000], d[200000];
  for (int i = 0, i_len = (int)(q); i < i_len; i++) {
    scanf(" %c %c", &t[i], &d[i]);
  }
  int ans = n;
  int pos;
  pos = -1;
  int max = -1;
  for (int i = (int)(q)-1; i >= 0; i--) {
    if (t[i] == s[pos + 1] && d[i] == 'L') {
      pos++;
    } else if (pos > 0) {
      if (t[i] == s[pos - 1] && d[i] == 'R') {
        pos--;
      }
    }
    max = Max(max, pos);
  }
  ans -= max + 1;
  pos = n;
  int min = n;
  for (int i = (int)(q)-1; i >= 0; i--) {
    if (t[i] == s[pos - 1] && d[i] == 'R') {
      pos--;
    } else if (pos < n - 1) {
      if (t[i] == s[pos + 1] && d[i] == 'L') {
        pos++;
      }
    }
    min = Min(min, pos);
  }
  ans -= n - min;
  printf("%d\n", (ans));
}
