#include <bits/stdc++.h>
using namespace std;
long long n, q;
string s;
char t[222222], d[222222];
signed main() {
  cin >> n >> q >> s;
  for (long long i = 0; i < q; i++) cin >> t[i] >> d[i];
  long long le = -1, ri = n;
  for (long long i = q - 1; i >= 0; i--) {
    if (s[le + 1] == t[i] && d[i] == 'L') le++;
    if (s[ri - 1] == t[i] && d[i] == 'R') ri--;
    if (le != -1 && s[le] == 'R') le--;
    if (ri != n && s[ri] == 'L') ri++;
  }
  cout << max(0ll, ri - le - 1) << endl;
}
