#include <bits/stdc++.h>
#pragma warning(disable : 4786)
#pragma warning(disable : 4996)
using namespace std;
char S[200005];
char t[200005][2], d[200005][2];
queue<int> Q[26][2];
int mark[200005];
void solve(int ks) {
  int n, q;
  scanf("%d %d", &n, &q);
  scanf("%s", S);
  for (int i = 1; i <= q; i++) {
    scanf("%s %s", t[i], d[i]);
  }
  int l = -1, r = n;
  for (int i = q; i >= 1; i--) {
    if (l + 1 >= r) {
      printf("%d\n", 0);
      return;
    }
    if (d[i][0] == 'L' && l + 1 < n && t[i][0] == S[l + 1]) {
      l++;
    }
    if (d[i][0] == 'R' && r - 1 >= 0 && t[i][0] == S[r - 1]) {
      r--;
    }
    if (l + 1 >= r) {
      printf("%d\n", 0);
      return;
    }
  }
  int ans = r - l - 1;
  printf("%d\n", ans);
}
int main() {
  if (0) {
    int T = 1000;
    scanf("%d", &T);
    for (int ks = 1; ks <= T; ks++) solve(ks);
  } else {
    solve(0);
  }
  return 0;
}
