#include <bits/stdc++.h>
using namespace std;
int N, Q;
string s;
char t[200005], d[200005];
int a, b;
int main() {
  cin >> N >> Q;
  cin >> s;
  for (int i = int(0); i < int(Q); ++i) cin >> t[i] >> d[i];
  int l = -1, r = N - 1;
  while (r - l > 1) {
    int m = (l + r) / 2;
    int p = m;
    for (int i = int(0); i < int(Q); ++i) {
      if (t[i] == s[p]) {
        if (d[i] == 'L')
          p--;
        else
          p++;
      }
      if (p < 0 || p >= N) break;
    }
    if (p >= 0)
      r = m;
    else
      l = m;
  }
  a = r;
  l = 0, r = N;
  while (r - l > 1) {
    int m = (l + r) / 2;
    int p = m;
    for (int i = int(0); i < int(Q); ++i) {
      if (t[i] == s[p]) {
        if (d[i] == 'L')
          p--;
        else
          p++;
      }
      if (p < 0 || p >= N) break;
    }
    if (p < N)
      l = m;
    else
      r = m;
  }
  b = l;
  cout << b - a + 1 << endl;
  return 0;
}
