#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
int n, m, dr[maxn];
char s[maxn], inD[maxn];
char Read() {
  char ch = getchar();
  while (ch < 'A' || ch > 'Z') ch = getchar();
  return ch;
}
int main() {
  scanf("%d %d", &n, &m);
  scanf("%s", s + 1);
  for (int i = 1; i <= m; i++) {
    char ch1 = Read(), ch2 = Read();
    inD[i] = ch1;
    dr[i] = (ch2 == 'R');
  }
  int ans = 0, l = 1, r = n;
  for (int i = m; i >= 1; i--) {
    if (s[l] == inD[i] && dr[i] == 0) l++, ans++;
    if (s[r] == inD[i] && dr[i] == 1) r--, ans++;
    if (ans == n) break;
  }
  printf("%d\n", n - ans);
}
