#include <bits/stdc++.h>
using namespace std;
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
int n, q;
string s;
vector<char> t(200000), d(200000);
bool safe_left(int pos) {
  int left = 0, num = 0;
  char cur = s[pos];
  for (int i = 0; i < (int)(q); ++i) {
    if (t[i] == cur) {
      if (d[i] == 'L') {
        if (pos == 0) return false;
        --num;
        left = min(left, num);
        cur = s[pos - 1];
      } else {
        ++num;
        cur = s[pos + 1];
      }
    }
  }
  if (pos + left >= 0)
    return true;
  else
    return false;
}
bool fall_right(int pos) {
  int right = 0, num = 0;
  char cur = s[pos];
  for (int i = 0; i < (int)(q); ++i) {
    if (t[i] == cur) {
      if (d[i] == 'R') {
        if (pos == n - 1) return true;
        ++num;
        right = max(right, num);
        cur = s[pos + 1];
      } else {
        --num;
        cur = s[pos - 1];
      }
    }
  }
  if (pos + right > n - 1)
    return true;
  else
    return false;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> q;
  cin >> s;
  for (int i = 0; i < (int)(q); ++i) cin >> t[i] >> d[i];
  int l1 = -1, l2 = -1, r1 = n, r2 = n;
  while (r1 - l1 > 1) {
    int m1 = (r1 + l1) / 2;
    if (safe_left(m1))
      r1 = m1;
    else
      l1 = m1;
  }
  while (r2 - l2 > 1) {
    int m2 = (r2 + l2) / 2;
    if (fall_right(m2))
      r2 = m2;
    else
      l2 = m2;
  }
  cout << (n - (r1 + (n - r2))) << '\n';
  return 0;
}
