#include <bits/stdc++.h>
using namespace std;
long long N, Q;
string s;
char t[223456], d[223456];
bool isOK(long long idx) {
  set<char> se;
  long long current = idx;
  for (long long i = 0, i_len = (Q); i < i_len; ++i) {
    se.insert(t[i]);
    if (se.count(s[idx])) {
      if (d[i] == 'L')
        current--;
      else
        current++;
      if (current < 0) return true;
      if (current >= N) return false;
      se.insert(s[current]);
    }
  }
  return false;
}
bool isOK2(long long idx) {
  set<char> se;
  long long current = idx;
  for (long long i = 0, i_len = (Q); i < i_len; ++i) {
    se.insert(t[i]);
    if (se.count(s[idx])) {
      if (d[i] == 'L')
        current--;
      else
        current++;
      if (current >= N) return true;
      if (current < 0) return false;
      se.insert(s[current]);
    }
  }
  return false;
}
signed main() {
  cin >> N >> Q;
  cin >> s;
  long long amin[26], amax[26], current[26];
  for (long long i = 0, i_len = (26); i < i_len; ++i) {
    amin[i] = (1LL << 60);
    amax[i] = -(1LL << 60);
    current[i] = 0;
  }
  for (long long i = 0, i_len = (Q); i < i_len; ++i) {
    cin >> t[i] >> d[i];
    long long idx = t[i] - 'A';
    if (d[i] == 'L')
      current[idx]--;
    else
      current[idx]++;
  }
  long long ok = -1;
  long long 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 left;
  if (ok == N)
    left = -1;
  else
    left = ok;
  cerr << "---" << endl;
  ok = N;
  ng = -1;
  while (abs(ok - ng) > 1) {
    long long mid = (ok + ng) / 2;
    cerr << mid << " " << isOK2(mid) << endl;
    if (isOK2(mid))
      ok = mid;
    else
      ng = mid;
  }
  long long right;
  if (ok == -1)
    right = N;
  else
    right = ok;
  cout << N - (left + 1) - (N - right) << endl;
  return 0;
}
