#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, Q;
  string s, ts, ds;
  cin >> N >> Q >> s;
  for (int n = 0; n < Q; n++) {
    char t, d;
    cin >> t >> d;
    ts = t + ts;
    ds = d + ds;
  }
  s = " " + s + " ";
  int l = 1, r = N;
  for (int i = 0; i < Q; i++) {
    char t = ts[i], d = ds[i];
    if (d == 'L') {
      if (s[l] == t && l != 0) l++;
      if (s[r + 1] == t && r != 0) r++;
    } else if (d == 'R') {
      if (s[r] == t && r != N + 1) r--;
      if (s[l - 1] == t && l != N + 1) l--;
    }
  }
  cout << r - l + 1 << endl;
}
