#include <bits/stdc++.h>
using namespace std;
int main() {
  long int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  char t[q], d[q];
  for (int i = 0; i < q; i++) cin >> t[i] >> d[i];
  string a, b;
  for (int i = 0; i < q; i++) {
    if (d[i] == 'L')
      a = t[i] + a;
    else
      b = b + t[i];
  }
  for (int i = 0; i < a.size(); i++) {
    if (a[i] == s[0]) s.erase(s.begin());
  }
  for (int i = b.size() - 1; i >= 0; i--) {
    if (b[i] == s[s.size() - 1]) s.pop_back();
  }
  cout << s.size() << endl;
}
