#include <bits/stdc++.h>
using namespace std;
int n, q;
char s[100001];
struct query {
  char pos;
  char dir;
};
query vec_q[100001];
bool 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--;
        square = s[val - 1];
      } else {
        val++;
        square = s[val - 1];
      }
      if (val > n || val < 1) return 0;
    }
  }
  return 1;
}
int best_left_out_right() {
  int st = 1;
  int dr = n;
  while (st <= dr) {
    int mij = (st + dr) / 2;
    if (verif(mij) == 0) {
      return mij;
    } else
      st = mij;
  }
}
int best_right_out_left() {
  int st = 1;
  int dr = n;
  while (st <= dr) {
    int mij = (st + dr) / 2;
    if (verif(mij) == 0) {
      return mij;
    } else
      dr = mij;
  }
}
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;
}
