#include <bits/stdc++.h>
using namespace std;
int N, Q;
char s[212345], t[212345], d[212345];
int f(int tmp) {
  for (long long q = 0; q < (Q); ++q) {
    if (t[q] == s[tmp]) {
      if (d[q] == 'L')
        --tmp;
      else
        ++tmp;
    }
  }
  if (tmp < 0)
    return -1;
  else if (tmp < N)
    return 0;
  else
    return 1;
}
int main() {
  scanf("%d%d%s", &N, &Q, s);
  for (long long i = 0; i < (Q); ++i) scanf("%c%c", &t[i], &d[i]);
  int l_l = 0, l_r = N - 1, r_l = 0, r_r = N - 1;
  while (l_r - l_l > 1) {
    int tmp = (l_l + l_r) / 2;
    if (f(tmp) == -1)
      l_l = tmp;
    else
      l_r = tmp;
  }
  if (f(l_r) == -1)
    l_l = l_r;
  else
    l_r = l_l;
  while (r_r - r_l > 1) {
    int tmp = (r_l + r_r) / 2;
    if (f(tmp) == 1)
      r_r = tmp;
    else
      r_l = tmp;
  }
  if (f(r_l) == 1)
    r_r = r_l;
  else
    r_l = r_r;
  if (f(l_l) != -1) l_l--;
  if (f(r_r) != 1) r_r++;
  printf("%d\n", N - l_l - 1 - (N - r_r));
  return 0;
}
