#include <bits/stdc++.h>
using namespace std;
int n, q, z, ok, ng;
string s;
char t[200000], d[200000];
int solve(int x) {
  if (z == 0) x--;
  for (int i = 0; i < q; i++)
    if (t[i] == s[x]) {
      if (d[i] == 'R')
        x++;
      else
        x--;
    }
  if (z == 0) {
    if (x < 0)
      return 1;
    else
      return 0;
  }
  if (z == 1) {
    if (x > n - 1)
      return 1;
    else
      return 0;
  }
}
int search() {
  while (abs(ok - ng) > 1) {
    int mid = (ok + ng) / 2;
    if (solve(mid))
      ok = mid;
    else
      ng = mid;
  }
}
int main() {
  cin >> n >> q >> s;
  for (int i = 0; i < q; i++) cin >> t[i] >> d[i];
  int ansL, ansR;
  z = 0;
  ok = 0;
  ng = n;
  search();
  ansL = ok;
  z = 1;
  ok = n;
  ng = 0;
  search();
  ansR = ok;
  cout << ansR - ansL;
}
