#include <bits/stdc++.h>
using namespace std;
long long N, Q;
string s;
char t[223456], d[223456];
bool isOK(long long idx) {
  for (long long i = 0, i_len = (Q); i < i_len; ++i) {
    if (s[idx] == t[i]) {
      if (d[i] == 'L')
        idx--;
      else
        idx++;
    }
    if (idx < 0) return false;
    if (idx >= N) return false;
  }
  return true;
}
signed main() {
  cin >> N >> Q;
  cin >> s;
  for (long long i = 0, i_len = (Q); i < i_len; ++i) cin >> t[i] >> d[i];
  long long ok = N;
  long long ng = -1;
  while (abs(ok - ng) > 1) {
    long long mid = (ok + ng) / 2;
    cerr << mid << " " << isOK(mid) << endl;
    if (isOK(mid))
      ok = mid;
    else
      ng = mid;
  }
  long long left;
  if (ok == N)
    left = -1;
  else
    left = ok;
  ok = -1;
  ng = N;
  while (abs(ok - ng) > 1) {
    long long mid = (ok + ng) / 2;
    cerr << mid << " " << isOK(mid) << endl;
    if (isOK(mid))
      ok = mid;
    else
      ng = mid;
  }
  long long right;
  if (ok == -1)
    right = N;
  else
    right = ok;
  cout << max(0LL, right - left + 1) << endl;
  return 0;
}
