#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 - 1;
  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;
    else
      lr = ((ll + lr) / 2) - 1;
  }
  rl = 0, rr = n - 1;
  while (rr - rl > 0) {
    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;
  }
  int spo = 0;
  for (int i = 0; i < (int)(q); i++) {
    if (s.at(spo) == t[i]) {
      if (d[i] == 'L')
        spo--;
      else
        spo++;
    }
    if (spo < 0 || spo > n - 1) break;
  }
  if (spo >= 0 && ll == 0) ll -= 1;
  spo = n - 1;
  for (int i = 0; i < (int)(q); i++) {
    if (s.at(spo) == t[i]) {
      if (d[i] == 'L')
        spo--;
      else
        spo++;
    }
    if (spo < 0 || spo > n - 1) break;
  }
  if (spo < n && rr == n - 1) rr += 1;
  cout << rr - ll - 1 << endl;
}
