#include <bits/stdc++.h>
using namespace std;
char t[200010];
char d[200010];
char s[200010];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  int n, q;
  cin >> n >> q;
  for (int i = 0; i < (int)(n); i++) cin >> s[i + 1];
  for (int i = 0; i < (int)(q); i++) cin >> t[i] >> d[i];
  s[0] = s[n + 1] = '_';
  int l = 0, r = n + 1;
  for (int i = q - 1; i >= 0; i--) {
    if (d[i] == 'L') {
      if (s[l + 1] == t[i]) l++;
    } else {
      if (s[r - 1] == t[i]) r--;
    }
  }
  cout << r - l - 1 << endl;
}
