#include <bits/stdc++.h>
using namespace std;
long long n, q;
string s;
char t[200010], d[200010];
bool func(long long x, bool b) {
  long long now = x;
  if (!b) {
    for (long long i = 0; i < q; i++) {
      if (t[i] == s[now] && d[i] == 'L') now--;
      if (now == -1) break;
    }
    if (now == -1) return true;
    return false;
  } else {
    for (long long i = 0; i < q; i++) {
      if (t[i] == s[now] && d[i] == 'R') now++;
      if (now == n) break;
    }
    if (now == n)
      return true;
    else
      return false;
  }
}
signed main() {
  cin >> n >> q >> s;
  for (long long i = 0; i < q; i++) cin >> t[i] >> d[i];
  long long mi = -1, ma = n;
  while (ma - mi > 1) {
    long long md = (mi + ma) / 2;
    if (func(md, false))
      mi = md;
    else
      ma = md;
  }
  if (func(ma, false)) mi++;
  long long ans = mi + 1;
  mi = -1, ma = n;
  while (ma - mi > 1) {
    long long md = (mi + ma) / 2;
    if (func(md, true))
      ma = md;
    else
      mi = md;
  }
  if (func(mi, true)) ma--;
  ans += n - ma;
  cout << n - ans << endl;
  getchar();
  getchar();
  return 0;
}
