#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using ld = long double;
using vl = vector<ll>;
using vd = vector<ld>;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int N, Q;
  cin >> N >> Q;
  string s;
  cin >> s;
  vector<char> alps(Q), LRs(Q);
  int lefout = -1;
  int rigout = N;
  for (int i = 0; i < Q; i++) {
    cin >> alps[i] >> LRs[i];
  }
  for (int i = Q - 1; i >= 0; i--) {
    if (LRs[i] == 'L') {
      if (s[lefout + 1] == alps[i]) {
        lefout++;
      }
    } else {
      if (s[rigout - 1] == alps[i]) {
        rigout--;
      }
    }
    if (lefout + 1 == rigout) break;
  }
  cout << rigout - lefout - 1;
  return 0;
}
