#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 7;
char s[N];
int mx[107], mi[107], now[107];
int main() {
  int n, q;
  scanf("%d%d", &n, &q);
  scanf("%s", s);
  for (int i = 1; i <= q; i++) {
    char x[2], y[2];
    scanf("%s%s", x, y);
    now[x[0] - 'A'] += (y[0] == 'L' ? -1 : 1);
    mx[x[0] - 'A'] = max(mx[x[0] - 'A'], now[x[0] - 'A']);
    mi[x[0] - 'A'] = min(mi[x[0] - 'A'], now[x[0] - 'A']);
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (i + mi[s[i] - 'A'] < 0 || i + mx[s[i] - 'A'] >= n) continue;
    ans += 1;
  }
  printf("%d", ans);
  return 0;
}
