#include <bits/stdc++.h>
using namespace std;
struct fast_ios {
  fast_ios() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  };
} fast_ios_;
using vec = vector<long long>;
using mat = vector<vec>;
using Pii = pair<long long, long long>;
using PiP = pair<long long, Pii>;
using PPi = pair<Pii, long long>;
using bools = vector<bool>;
using pairs = vector<Pii>;
template <typename T>
void readv(vector<T> &a) {
  for (long long i = (0); i < (a.size()); i++) cin >> a[i];
}
void readv_m1(vector<long long> &a) {
  for (long long i = (0); i < (a.size()); i++) {
    cin >> a[i];
    a[i]--;
  }
}
long long mod = 1000000007;
signed main() {
  long long N, Q;
  cin >> N >> Q;
  string second;
  cin >> second;
  vector<char> t(Q), d(Q);
  vec D(N);
  for (long long i = (0); i < (Q); i++) {
    cin >> t[i] >> d[i];
    if (d[i] == 'L')
      D[i] = -1;
    else
      D[i] = 1;
  }
  long long i1 = -1, i2 = N;
  while (i2 - i1 > 1) {
    long long i0 = (i1 + i2) / 2;
    long long now = i0;
    bool fall = false;
    for (long long i = (0); i < (Q); i++)
      if (t[i] == second[now]) {
        now += D[i];
        if (now >= N) break;
        if (now < 0) {
          fall = true;
          break;
        }
      }
    if (fall)
      i1 = i0;
    else
      i2 = i0;
  }
  long long j1 = -1, j2 = N;
  while (j2 - j1 > 1) {
    long long j0 = (j1 + j2) / 2;
    long long now = j0;
    bool fall = false;
    for (long long i = (0); i < (Q); i++)
      if (t[i] == second[now]) {
        now += D[i];
        if (now < 0) break;
        if (now >= N) {
          fall = true;
          break;
        }
      }
    if (fall)
      j2 = j0;
    else
      j1 = j0;
  }
  long long ans = j1 - i1;
  cout << ans << endl;
  return 0;
}
