#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll N, Q;
string s;
vector<char> t, d;
void input() {
  cin >> N >> Q >> s;
  t.resize(N);
  d.resize(N);
  for (ll i = 0; i < Q; i++) {
    cin >> t[i] >> d[i];
  }
}
ll goal(ll p) {
  for (ll i = 0; i < Q; i++) {
    if (s[p] == t[i]) {
      if (d[i] == 'L')
        p--;
      else
        p++;
    }
    if (p < 0 or p >= N) return p;
  }
  return p;
}
ll solve() {
  vector<ll> spos[0xff];
  for (ll i = 0; i < N; i++) {
    spos[ll(s[i])].push_back(i);
  }
  ll dels = 0;
  ll l = 0, r = N - 1;
  ll c = (l + r) / 2;
  while (l <= r) {
    if (goal(c) < 0) {
      dels += c - l + 1;
      l = c + 1;
    } else {
      r = c - 1;
    }
    c = (l + r) / 2;
  }
  l = 0, r = N - 1;
  while (l <= r) {
    if (goal(c) >= N) {
      dels += r - c + 1;
      r = c - 1;
    } else {
      l = c + 1;
    }
    c = (l + r) / 2;
  }
  return N - dels;
}
int main() {
  input();
  cout << solve() << endl;
  return 0;
}
