#include <bits/stdc++.h>
using namespace std;
bool rgt(vector<int>& vs, vector<int>& t, vector<int>& d, int ptr) {
  auto n = vs.size();
  auto q = t.size();
  if (ptr >= n) return true;
  for (int i = 0; i < q; ++i) {
    if (vs[ptr] != t[i]) continue;
    ptr += d[i];
    if (ptr + q - i < n) break;
    if (ptr == n) return true;
  }
  return false;
}
bool lft(vector<int>& vs, vector<int>& t, vector<int>& d, int ptr) {
  auto n = vs.size();
  auto q = t.size();
  if (ptr >= n) return false;
  if (ptr < 0) return true;
  for (int i = 0; i < q; ++i) {
    if (vs[ptr] != t[i]) continue;
    ptr += d[i];
    if (ptr < 0) return true;
    if (q - i < ptr) break;
  }
  return false;
}
int main() {
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<int> vs;
  for (auto ch : s) {
    vs.push_back(ch - 'A');
  }
  vector<int> t(q), d(q);
  for (int i = 0; i < q; ++i) {
    char ch;
    cin >> ch;
    t[i] = ch - 'A';
    cin >> ch;
    d[i] = (ch == 'R') ? 1 : -1;
  }
  int ptr = n / 2;
  int stp = ptr / 2 + 1;
  int loop_max = 2 * log2(n) + 1;
  for (int iii = 0; iii < loop_max; ++iii) {
    bool hr = rgt(vs, t, d, ptr);
    bool nx = rgt(vs, t, d, ptr + 1);
    if ((!hr) & nx) break;
    if (hr) {
      ptr = max(ptr - stp, 0);
    } else {
      ptr = min(n - 1, ptr + stp);
    }
    stp = (stp + 1) / 2;
  }
  auto r = ptr;
  ptr = r / 2;
  stp = ptr / 2 + 1;
  while (true) {
    bool hr = lft(vs, t, d, ptr);
    bool nx = lft(vs, t, d, ptr - 1);
    if (nx & !hr) break;
    if (!hr) {
      ptr = max(ptr - stp, 0);
    } else {
      ptr = min(n - 1, ptr + stp);
    }
    stp = (stp + 1) / 2;
  }
  cout << r - ptr + 1 << endl;
  return 0;
}
