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