#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q;
  cin >> n >> q;
  vector<char> s(n + 2);
  s[0] = 'n';
  s[n + 1] = 'n';
  for (int i = 1; i <= n; ++i) cin >> s[i];
  vector<char> t(q), d(q);
  for (int i = 0; i < (q); ++i) {
    cin >> t[i] >> d[i];
  }
  int left = 0, right = n + 1;
  for (int i = q - 1; i >= 0; --i) {
    if (d[i] == 'L') {
      if (t[i] == s[left + 1])
        left++;
      else if (t[i] == s[right])
        right++;
    } else {
      if (t[i] == s[right - 1])
        right--;
      else if (t[i] == s[left])
        left--;
    }
  }
  cout << max(0, right - left - 1) << endl;
  return 0;
}
