#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, Q;
  cin >> N >> Q;
  string S;
  cin >> S;
  S = "*" + S + "*";
  int x = 0, y = N + 1;
  int l = 0, r = N + 1;
  vector<char> t(Q), d(Q);
  for (int i = (int)(0); i < (int)(Q); ++i) cin >> t[i] >> d[i];
  for (int i = (int)(Q - 1); i > (int)(-1); --i) {
    if (d[i] == 'L') {
      if (S[l + 1] == t[i]) ++l;
      if (S[r] == t[i]) ++r;
    } else {
      if (S[l] == t[i]) --l;
      if (S[r - 1] == t[i]) --r;
    }
    x = max(x, l);
    y = min(y, r);
  }
  cout << N - min(N, x + N + 1 - y) << endl;
  return 0;
}
