#include <bits/stdc++.h>
using namespace std;
int dy[5] = {0, 0, 1, -1, 0};
int dx[5] = {1, -1, 0, 0, 0};
int main(void) {
  int n, q;
  int count;
  string s;
  string rev;
  string left, right;
  char t, d;
  int leftm = 0;
  int rightm = 0;
  cin >> n >> q;
  cin >> s;
  rev = s;
  count = n;
  reverse(rev.begin(), rev.end());
  for (int i = (1); i <= (q); i++) {
    cin >> t >> d;
    if (d == 'L') {
      left += t;
    } else {
      right += t;
    }
  }
  reverse(left.begin(), left.end());
  reverse(right.begin(), right.end());
  int pos = 0;
  int p;
  for (int i = (0); i <= (left.size() - 1); i++) {
    if (left[i] == s[pos]) {
      pos++;
    }
  }
  leftm = max(leftm, pos);
  pos = 0;
  for (int i = (0); i <= (right.size() - 1); i++) {
    if (right[i] == rev[pos]) {
      pos++;
    }
  }
  rightm = max(rightm, pos);
  pos = 0;
  if (rightm + leftm >= n) {
    cout << 0 << endl;
  } else {
    cout << n - rightm - leftm << endl;
  }
  return 0;
}
