#include <bits/stdc++.h>
using namespace std;
int rl, rr;
int ll, lr;
int n, q;
string s;
char t[200001], d[200001];
int main() {
  cin >> n >> q;
  cin >> s;
  int lr, ll;
  for (int i = 0; i < (int)(q); i++) cin >> t[i] >> d[i];
  ll = 0, lr = n;
  while (lr - ll > 0) {
    int mid = (ll + lr) / 2;
    for (int i = 0; i < (int)(q); i++) {
      if (s.at(mid) == t[i]) {
        if (d[i] == 'L')
          mid--;
        else
          mid++;
      }
      if (mid < 0 || mid > n - 1) break;
    }
    if (mid < 0)
      ll = ((ll + lr) / 2) + 1;
    else
      lr = ((ll + lr) / 2);
  }
  rl = 0, rr = n;
  while (rr - rl > 1) {
    int mid = (rl + rr) / 2;
    for (int i = 0; i < (int)(q); i++) {
      if (s.at(mid) == t[i]) {
        if (d[i] == 'L')
          mid--;
        else
          mid++;
      }
      if (mid < 0 || mid > n - 1) break;
    }
    if (mid > n - 1)
      rr = ((rl + rr) / 2);
    else
      rl = ((rl + rr) / 2) + 1;
  }
  cout << rr - ll << endl;
}
