#include <bits/stdc++.h>
using namespace std;
int N, Q;
string s;
int t[200000];
int d[200000];
vector<int> v[26];
int check(int i, int lr, int num) {
  if (i < 0 || N <= i) {
    if (lr) {
      if (N <= i) {
        return 1;
      }
    } else {
      if (i < 0) {
        return 1;
      }
    }
    return 0;
  }
  int n = s[i] - 'A';
  int res = 0;
  for (int j = 0; j < v[n].size(); j++) {
    int k = v[n][j];
    if (k <= num) {
      continue;
    }
    int dd = d[k];
    if (dd) {
      res |= check(i + 1, lr, k);
    } else {
      res |= check(i - 1, lr, k);
    }
  }
  return res;
}
int main() {
  cin >> N >> Q >> s;
  for (int i = 0; i < Q; i++) {
    char ct, cd;
    cin >> ct >> cd;
    t[i] = ct - 'A';
    d[i] = 0;
    if (cd == 'R') {
      d[i] = 1;
    }
  }
  for (int i = 0; i < Q; i++) {
    v[t[i]].push_back(i);
  }
  int l = -1;
  int r = N;
  while (r - l > 1) {
    int m = (r + l) / 2;
    if (check(m, 0, -1)) {
      l = m;
    } else {
      r = m;
    }
  }
  int cl = l;
  l = -1;
  r = N;
  while (r - l > 1) {
    int m = (r + l) / 2;
    if (check(m, 1, -1)) {
      r = m;
    } else {
      l = m;
    }
  }
  int cr = r;
  int ans = max(N - (N - cr) - (cl + 1), 0);
  cout << ans << endl;
  return 0;
}
