#include <bits/stdc++.h>
using namespace std;
int n, q;
string s;
char t[200000], d[200000];
int main(void) {
  cin >> n >> q >> s;
  for (int i = 0; i < q; i++) {
    cin >> t[i] >> d[i];
  }
  int l = -1, r = n;
  for (int i = q - 1; i >= 0; i--) {
    if (l + 1 <= n + 1) {
      if (d[i] == 'L' && t[i] == s[l + 1]) {
        l++;
      }
    }
    if (r - 1 >= 0) {
      if (d[i] == 'R' && t[i] == s[r - 1]) {
        r--;
      }
    }
  }
  int a = max(0, r - l - 1);
  cout << a << endl;
}
