#include <bits/stdc++.h>
using namespace std;
int N, Q;
char s[200010];
char t[200010];
char d[200010];
int check(int p) {
  int x = p;
  for (int i = 1; i <= Q; i++) {
    if (t[i] == s[x]) {
      if (d[i] == 'R')
        x++;
      else
        x--;
    }
    if (x <= 0) return 0;
    if (x > N) return 1;
  }
  if (x == N)
    return 2;
  else if (x == 1)
    return 3;
  else
    return 4;
}
int main() {
  scanf("%d%d", &N, &Q);
  for (int i = 1; i <= N; i++) cin >> s[i];
  for (int i = 1; i <= Q; i++) {
    cin >> t[i] >> d[i];
  }
  int l = 1, r = N;
  while (l < r) {
    int mid = (l + r) / 2;
    if (check(mid) == 0) {
      l = mid + 1;
    } else
      r = mid - 1;
  }
  int num = N - l + 1;
  int long long = 1, rr = N;
  while (long long <= rr) {
    int midmid = (long long + rr) / 2;
    if (check(midmid) == 1) {
      rr = midmid - 1;
    } else {
      long long = midmid + 1;
    }
  }
  num = num - (N - rr);
  cout << num - 1 << endl;
  return 0;
}
