#include <bits/stdc++.h>
using namespace std;
long long int N, Q;
char S[200005];
long long int ans = 0;
char t[200005], d[200005];
signed main() {
  scanf("%lld %lld", &N, &Q);
  scanf("%s", S);
  for (long long int i = 0; i < Q; i++) {
    char lf;
    scanf("%c", &lf);
    scanf("%c %c", &t[i], &d[i]);
  }
  long long int gorem_r = N;
  long long int gorem_l = -1;
  for (long long int i = 0; i < Q; i++) {
    long long int j = Q - 1 - i;
    if (gorem_l + 1 == gorem_r) break;
    if (d[j] == 'L' && S[gorem_l + 1] == t[j]) {
      gorem_l++;
    } else if (d[j] == 'R' && S[gorem_r - 1] == t[j]) {
      gorem_r--;
    }
  }
  ans = gorem_r - gorem_l - 1;
  printf("%lld\n", ans);
}
