#include <bits/stdc++.h>
using namespace std;
const long long INF = (1ll << 60);
int main() {
  long long N, Q;
  cin >> N >> Q;
  string s;
  cin >> s;
  vector<long long> v;
  for (char c : s) v.push_back(c - 'A');
  vector<long long> t(Q), d(Q);
  for (long long i = 0; i < Q; i++) {
    char a, b;
    cin >> a >> b;
    t[i] = a - 'A';
    d[i] = b == 'L' ? 0 : 1;
  }
  auto simulate = [&](long long i) {
    for (long long j = 0; j < Q; j++) {
      if (t[j] == v[i]) {
        if (i == 0 && d[j] == 0) return -1;
        if (i == N - 1 && d[j] == 1) return 1;
        if (d[j] == 0) i -= 1;
        if (d[j] == 1) i += 1;
      }
    }
    return 0;
  };
  long long ans = N;
  long long l = 0, r = N;
  while (r - l > 1) {
    long long mid = (r + l) / 2 - 1;
    if (simulate(mid) == -1)
      l = mid + 1;
    else
      r = mid + 1;
  }
  ans -= l;
  l = 0, r = N;
  while (r - l > 1) {
    long long mid = (r + l) / 2;
    if (simulate(mid) == 1)
      r = mid;
    else
      l = mid;
  }
  ans -= (N - 1 - (l + 1) + 1);
  cout << ans << endl;
}
