#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<char> l, r;
  for (int i = 0; i < (q); i++) {
    char c, d;
    cin >> c >> d;
    if (d == 'L')
      l.push_back(c);
    else
      r.push_back(c);
  }
  reverse(l.begin(), l.end());
  reverse(r.begin(), r.end());
  int lp = 0, rp = 0;
  for (int i = 0; i < (l.size()); i++) {
    if (l[i] == s[lp]) lp++;
  }
  for (int i = 0; i < (r.size()); i++) {
    if (r[i] == s[n - 1 - rp]) rp++;
  }
  cout << n - rp - lp << endl;
  return 0;
}
