#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using namespace std;
template <class T>
void vin(vector<T>& v, int n) {
  v.resize(n);
  for (int i = 0; i < n; ++i) {
    cin >> v[i];
  }
}
int N, Q;
string s;
char t[200001], d[200001];
bool ok1(int m) {
  int idx = m;
  char cur = s[idx];
  for (int(i) = (0); (i) < (int)(Q); ++(i)) {
    if (cur == t[i]) {
      if (d[i] == 'L') {
        idx--;
        cur = s[idx];
      } else {
        idx++;
        cur = s[idx];
      }
    }
    if (idx == 0 or idx == N + 1) break;
  }
  return idx == 0;
}
bool ok2(int m) {
  int idx = m;
  char cur = s[idx];
  for (int(i) = (0); (i) < (int)(Q); ++(i)) {
    if (cur == t[i]) {
      if (d[i] == 'L') {
        idx--;
        cur = s[idx];
      } else {
        idx++;
        cur = s[idx];
      }
    }
    if (idx == 0 or idx == N + 1) break;
  }
  return idx == N + 1;
}
int main() {
  cin >> N >> Q >> s;
  for (int(i) = (0); (i) < (int)(Q); ++(i)) cin >> t[i] >> d[i];
  s = "x" + s + "x";
  int ans = 0;
  {
    int l = 0, r = N + 2;
    while (r - l > 1) {
      int m = (l + r) / 2;
      if (ok1(m))
        l = m;
      else
        r = m;
    }
    ans = (r - 1);
    if (ans < 0) ans = 0;
  }
  {
    int l = 0, r = N + 2;
    while (r - l > 1) {
      int m = (l + r) / 2;
      if (ok2(m))
        r = m;
      else
        l = m;
    }
    int tmp = N - r + 1;
    if (tmp < 0) tmp = 0;
    ans += tmp;
  }
  cout << N - ans << endl;
}
