#include <bits/stdc++.h>
using namespace std;
int n, q;
char s[200001];
struct query {
  char pos;
  char dir;
};
query vec_q[200001];
int verif(int val) {
  char square = s[val - 1];
  for (int i = 1; i <= q; i++) {
    if (vec_q[i].pos == square) {
      if (vec_q[i].dir == 'L')
        val--;
      else
        val++;
      if (val > n)
        return -1;
      else if (val < 1)
        return -2;
      square = s[val - 1];
    }
  }
  return 1;
}
int best_left_out_right() {
  int st = 1;
  int dr = n;
  int sol;
  int pp = 0;
  while (st <= dr) {
    int mij = (st + dr) / 2;
    if (verif(mij) == 1)
      st = mij + 1;
    else if (verif(mij) == -1) {
      pp = 1;
      sol = mij;
      dr = mij - 1;
    }
  }
  if (!pp) return n + 1;
  return sol;
}
int best_right_out_left() {
  int st = 1;
  int dr = n;
  int sol;
  int pp = 0;
  while (st <= dr) {
    int mij = (st + dr) / 2;
    if (verif(mij) == 1) {
      dr = mij - 1;
    } else if (verif(mij) == -2) {
      pp = 1;
      st = mij + 1;
      sol = mij;
    }
  }
  if (!pp) return 0;
  return sol;
}
int main() {
  cin >> n >> q;
  cin >> s;
  for (int i = 1; i <= q; i++) {
    cin >> vec_q[i].pos >> vec_q[i].dir;
  }
  int val_1 = best_left_out_right();
  int val_2 = best_right_out_left();
  cout << n - val_2 - (n - val_1 + 1);
  return 0;
}
