#include <bits/stdc++.h>
using namespace std;
const long long MOD = long long(1e9 + 7);
const int IINF = INT_MAX;
const long long LLINF = LLONG_MAX;
const int MAX_N = int(2e4 + 5);
const double EPS = 1e-6;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
int n, q;
string s, t[MAX_N], d[MAX_N];
bool check(int k, bool f) {
  int pos = k;
  char now = s[k];
  for (int i = 0; i < q; i++) {
    if (now == t[i][0]) {
      if (d[i] == "L") {
        now = s[pos - 1];
        pos--;
      } else {
        now = s[pos + 1];
        pos++;
      }
    }
  }
  if (f)
    return pos == 0;
  else
    return pos == n + 1;
}
int main() {
  cin >> n >> q >> s;
  s.insert(0, "#");
  s.push_back('#');
  for (int i = 0; i < q; i++) {
    cin >> t[i] >> d[i];
  }
  int l, r;
  int ok = 0, ng = n + 1;
  while (abs(ok - ng) > 1) {
    int mid = (ok + ng) / 2;
    if (check(mid, true)) {
      ok = mid;
    } else {
      ng = mid;
    }
  }
  l = ok;
  ok = n + 1, ng = 0;
  while (abs(ok - ng) > 1) {
    int mid = (ok + ng) / 2;
    if (check(mid, false)) {
      ok = mid;
    } else {
      ng = mid;
    }
  }
  r = ok;
  cout << r - l - 1 << endl;
  return 0;
}
