#include <bits/stdc++.h>
using namespace std;
int N, Q;
string s;
char t[100010], d[100010];
bool judge(int mid, int x) {
  int now = mid - 1;
  for (int i = 0; i < Q; i++) {
    if (s[now] == t[i]) {
      if (d[i] == 'L')
        now = now - 1;
      else
        now = now + 1;
    }
    if (now == x)
      return true;
    else if (x == N && now == -1)
      return false;
    else if (x == -1 && now == N)
      return false;
  }
  return false;
}
int main() {
  cin >> N >> Q;
  cin >> s;
  for (int i = 0; i < Q; i++) {
    cin >> t[i] >> d[i];
  }
  int ok = 0, ng = N + 1;
  while (ng - ok > 1) {
    int mid = (ok + ng) / 2;
    if (judge(mid, -1))
      ok = mid;
    else
      ng = mid;
  }
  int ans = ok;
  ok = N + 1;
  ng = 0;
  while (ok - ng > 1) {
    int mid = (ok + ng) / 2;
    if (judge(mid, N))
      ok = mid;
    else
      ng = mid;
  }
  cout << N - min(ans + N - ok + 1, N) << endl;
  return 0;
}
