#include <bits/stdc++.h>
using namespace std;
const long long e5 = 1 << 21;
const long long mod = 1000000007;
const long long e3 = 1 << 13;
const long long INF = 1ll << 60;
long long n, q;
string $;
char s[e5];
char t[e5];
char d[e5];
long long ans_l, ans_r;
bool solve_left(long long x) {
  for (long long i = 0; i < q; i++) {
    if (s[x] == t[i]) {
      if (d[i] == 'L')
        x--;
      else
        x++;
      if (x <= 0) return true;
      if (x > n) return false;
    }
  }
  return false;
}
bool solve_right(long long x) {
  for (long long i = 0; i < q; i++) {
    if (s[x] == t[i]) {
      if (d[i] == 'L')
        x--;
      else
        x++;
      if (x <= 0) return true;
      if (x > n) return false;
    }
  }
  return true;
}
int main() {
  cin >> n >> q;
  cin >> $;
  for (long long i = 1; i <= n; i++) {
    s[i] = $[i - 1];
  }
  for (long long i = 0; i < q; i++) {
    cin >> t[i] >> d[i];
  }
  long long bottom = 0;
  long long top = n + 1;
  while (top - bottom > 1) {
    long long middle = (top + bottom) / 2;
    if (solve_left(middle))
      bottom = middle;
    else
      top = middle;
  }
  ans_l = bottom;
  bottom = 0;
  top = n + 1;
  while (top - bottom > 1) {
    long long middle = (top + bottom) / 2;
    if (solve_right(middle))
      bottom = middle;
    else
      top = middle;
  }
  ans_r = top;
  cerr << ans_l << " " << ans_r << endl;
  cout << ans_r - ans_l - 1 << endl;
}
