#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, Q;
  cin >> N >> Q;
  string s;
  cin >> s;
  vector<string> t(Q);
  vector<string> d(Q);
  for (int i = 0; i < Q; i++) {
    cin >> t[i] >> d[i];
  }
  int pos_r = N - 1;
  for (int i = N - 1; i >= 0; i--) {
    int pos = i;
    bool flag2 = true;
    for (int j = 0; j < Q; j++) {
      if (s[pos] == t[j][0]) {
        if (d[j] == "R") {
          pos++;
        }
        if (d[j] == "L") {
          pos--;
        }
      }
      if (pos >= N) {
        flag2 = false;
        break;
      }
    }
    if (flag2) {
      pos_r = i;
      break;
    }
  }
  int pos_l = pos_r + 1;
  for (int i = 0; i <= pos_r; i++) {
    int pos = i;
    bool flag2 = true;
    for (int j = 0; j < Q; j++) {
      if (s[pos] == t[j][0]) {
        if (d[j] == "R") {
          pos++;
        }
        if (d[j] == "L") {
          pos--;
        }
      }
      if (pos < 0) {
        flag2 = false;
        break;
      }
    }
    if (flag2) {
      pos_l = i;
      break;
    }
  }
  cout << pos_r - pos_l + 1 << endl;
  return 0;
}
