#include <bits/stdc++.h>
using namespace std;
int n;
int si[200010];
pair<int, int> query[200010];
bool check(int now, int d2) {
  for (auto v : query) {
    int t = v.first;
    int d = v.second;
    if (si[now] == t) {
      if (d == 0)
        now++;
      else
        now--;
    }
    if (now == n) return d2 == 0;
    if (now == -1) return d2 == 1;
  }
  return false;
}
int main() {
  int q;
  char s[200010];
  scanf("%d%d", &n, &q);
  scanf("%s", s);
  for (int i = 0; i < n; i++) si[i] = s[i] - 'A';
  for (int i = 0; i < q; i++) {
    char t, d;
    scanf(" %c %c", &t, &d);
    query[i] = {t - 'A', d == 'L'};
  }
  int L = -1, R = n;
  int l = -1, r = n;
  while (l < r) {
    int mid = (l + r + 1) / 2;
    if (check(mid, 1))
      l = mid;
    else
      r = mid - 1;
  }
  L = l;
  l = -1, r = n;
  while (l < r) {
    int mid = (l + r) / 2;
    if (check(mid, 0))
      r = mid;
    else
      l = mid + 1;
  }
  R = l;
  int ans = 0;
  ;
  ;
  ;
  ;
  for (int i = 0; i < n; i++) {
    ans += i <= L || R <= i;
  }
  cout << n - ans << endl;
  return 0;
}
