#include <bits/stdc++.h>
using namespace std;
const int MAX = 200002;
int main() {
  int N, Q;
  static char t[MAX], d[MAX];
  string s;
  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 (s[l + 1] == t[i] && d[i] == 'L') ++l;
    if (0 <= l && s[l] == t[i] && d[i] == 'R') --l;
    if (s[r - 1] == t[i] && d[i] == 'R') --r;
    if (r < N && s[r] == t[i] && d[i] == 'l') ++r;
    if (r - l <= 1) break;
  }
  cout << max(0, r - l - 1);
  return 0;
}
