#include <bits/stdc++.h>
using namespace std;
const int MAXN = 234567;
char s[MAXN];
int t[MAXN], d[MAXN];
bool check1(int ans, int N, int Q) {
  int cur = ans;
  for (int i = 0; i < Q; i++) {
    if (s[cur] - 'A' != t[i]) continue;
    cur += d[i];
    if (cur < 0) return true;
  }
  return false;
}
bool check2(int ans, int N, int Q) {
  int cur = ans;
  for (int i = 0; i < Q; i++) {
    if (s[cur] - 'A' != t[i]) continue;
    cur += d[i];
    if (cur >= N) return true;
  }
  return false;
}
int main() {
  int N, Q;
  scanf("%d %d", &N, &Q);
  scanf("%s", s);
  for (int i = 0; i < Q; i++) {
    char tmp[6];
    scanf("%s", tmp);
    t[i] = tmp[0] - 'A';
    scanf("%s", tmp);
    if (tmp[0] == 'R')
      d[i] = 1;
    else
      d[i] = -1;
  }
  int l = 0, r = N + 1, ans1 = -1, ans2 = N;
  while (l < r) {
    int mid = (l + r) / 2;
    if (check1(mid, N, Q)) {
      ans1 = mid;
      l = mid + 1;
    } else
      r = mid;
  }
  l = 0, r = N + 1;
  while (l < r) {
    int mid = (l + r) / 2;
    if (check2(mid, N, Q)) {
      ans2 = mid;
      r = mid;
    } else
      l = mid + 1;
  }
  int ans = N;
  ans -= (ans1 + 1);
  ans -= (N - ans2);
  if (ans < 0) ans = 0;
  printf("%d\n", ans);
  return 0;
}
