#include <bits/stdc++.h>
using namespace std;
int drop(int n, int N, int Q, string s, char t[], char d[]) {
  int i, posi = n;
  for (i = 1; i <= Q; i++) {
    if (s[posi - 1] == t[i]) {
      if (d[i] == 'R') {
        posi++;
        if (posi > N) return 1;
      } else {
        posi--;
        if (posi < 1) return -1;
      }
    }
  }
  return 0;
}
int main() {
  int i, N, Q, LL, LR, RL, RR, LM, RM, ans;
  char t[220000], d[220000];
  string s;
  cin >> N >> Q;
  cin >> s;
  for (i = 1; i <= N; i++) {
    cin >> t[i] >> d[i];
  }
  LL = 0;
  RL = 0;
  LR = N + 1;
  RR = N + 1;
  while (1) {
    LM = (LL + LR) / 2;
    if (drop(LM, N, Q, s, t, d) == -1)
      LL = LM;
    else
      LR = LM;
    if (LR - LL == 1) break;
  }
  while (1) {
    RM = (RL + RR) / 2;
    if (drop(RM, N, Q, s, t, d) == 1)
      RR = RM;
    else
      RL = RM;
    if (RR - RL == 1) break;
  }
  ans = RR - LR;
  cout << ans << endl;
}
