#include <bits/stdc++.h>
using namespace std;
template <class T>
void read(T &res) {
  res = 0;
  T f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    res = res * 10 + c - '0';
    c = getchar();
  }
  res *= f;
}
template <class T>
void out(T x) {
  if (x < 0) {
    x = -x;
    putchar('-');
  }
  if (x >= 10) {
    out(x / 10);
  }
  putchar('0' + x % 10);
}
int N, Q;
char s[20005];
pair<int, int> op[20005];
int getplace(int p) {
  for (int i = 1; i <= Q; ++i) {
    if (s[p] == 'A' + op[i].first) {
      p += op[i].second;
    }
  }
  return p;
}
int findL() {
  int L = 0, R = N;
  while (L < R) {
    int mid = (L + R + 1) >> 1;
    if (getplace(mid) == 0)
      L = mid;
    else
      R = mid - 1;
  }
  return L;
}
int findR() {
  int L = 1, R = N + 1;
  while (L < R) {
    int mid = (L + R) >> 1;
    if (getplace(mid) == N + 1)
      R = mid;
    else
      L = mid + 1;
  }
  return L;
}
void Solve() {
  read(N);
  read(Q);
  scanf("%s", s + 1);
  char t[5], d[5];
  for (int i = 1; i <= Q; ++i) {
    scanf("%s%s", t + 1, d + 1);
    int a, b;
    if (d[1] == 'L')
      b = -1;
    else
      b = 1;
    a = t[1] - 'A';
    op[i] = make_pair(a, b);
  }
  int L = findL(), R = findR();
  out(R - L - 1);
  putchar('\n');
}
int main() {
  Solve();
  return 0;
}
