#include <bits/stdc++.h>
using namespace std;
int INF = 2147483647;
long long LINF = 9223372036854775807;
long long MOD = 1000000007;
int main() {
  int n, q;
  cin >> n >> q;
  char s[n + 2];
  for (int i = 0; i < n; ++i) cin >> s[i + 1];
  s[0] = '0';
  s[n + 1] = '0';
  char t[q], d[q];
  for (int i = 0; i < q; ++i) {
    cin >> t[i] >> d[i];
  }
  int l = 0;
  int r = n + 1;
  int lmax = 0;
  int rmin = n + 1;
  for (int i = q - 1; i > -1; --i) {
    if (l < n)
      if (t[i] == s[l + 1] && d[i] == 'L') ++l;
    if (r > 0)
      if (t[i] == s[r - 1] && d[i] == 'R') --r;
    lmax = max(lmax, l);
    rmin = min(rmin, r);
  }
  cout << max(0, rmin - lmax - 1) << endl;
  return 0;
}
