#include <bits/stdc++.h>
using namespace std;
int64_t mod = 1e9 + 7;
int64_t INF = 1e9 + 18;
int64_t n, q;
string s;
char t[200001], l[200001];
bool f(int64_t cur, int64_t d) {
  for (int64_t i = 0; i < q; i++) {
    if (s[cur] == t[i]) {
      if (l[i] == 'L') {
        cur--;
      } else {
        cur++;
      }
    }
  }
  return cur == d;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> q;
  cin >> s;
  s = '.' + s + '.';
  for (int64_t i = 0; i < q; i++) cin >> t[i] >> l[i];
  int64_t res = n;
  int64_t ok = 1;
  int64_t ng = n + 1;
  while (abs(ok - ng) > 1) {
    int64_t mid = (ok + ng) / 2;
    if (f(mid, 0)) {
      ok = mid;
    } else {
      ng = mid;
    }
  }
  res -= ok;
  if (ok == 1 && !f(1, 0)) res++;
  ok = n;
  ng = 0;
  while (abs(ok - ng) > 1) {
    int64_t mid = (ok + ng) / 2;
    if (f(mid, n + 1)) {
      ok = mid;
    } else {
      ng = mid;
    }
  }
  res -= n - ok + 1;
  if (ok == n && !f(1, n + 1)) res++;
  cout << (res) << '\n';
  ;
  return 0;
}
