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