#include <bits/stdc++.h>
using namespace std;
int N, Q;
string s;
vector<pair<int, int>> com;
vector<vector<int>> M(26, vector<int>());
bool isOK_l(int v) {
  if (v == -1) return true;
  for (int i = 0; i < Q; ++i) {
    char t = com[i].first;
    char d = com[i].second;
    for (auto &p : M[t - 'A']) {
      if (p != v) continue;
      if (d == 'R')
        v++;
      else
        v--;
      break;
    }
    if (v == -1) return true;
    if (v == N) return false;
  }
  return false;
}
int bs_l() {
  int ng = N;
  int ok = -1;
  while (abs(ok - ng) > 1) {
    int mid = (ok + ng) / 2;
    if (isOK_l(mid))
      ok = mid;
    else
      ng = mid;
  }
  return ok;
}
bool isOK_r(int v) {
  if (v == N) return true;
  for (int i = 0; i < Q; ++i) {
    char t = com[i].first;
    char d = com[i].second;
    for (auto &p : M[t - 'A']) {
      if (p != v) continue;
      if (d == 'R')
        v++;
      else
        v--;
      break;
    }
    if (v == N) return true;
    if (v == -1) return false;
  }
  return false;
}
int bs_r() {
  int ng = -1;
  int ok = N;
  while (abs(ok - ng) > 1) {
    int mid = (ok + ng) / 2;
    if (isOK_r(mid))
      ok = mid;
    else
      ng = mid;
  }
  return ok;
}
int main() {
  cin >> N >> Q >> s;
  for (int i = 0; i < Q; ++i) {
    char a, b;
    cin >> a >> b;
    com.emplace_back(a, b);
  }
  for (int i = 0; i < N; ++i) M[s[i] - 'A'].push_back(i);
  cout << bs_r() - bs_l() - 1 << endl;
  return 0;
}
