#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 10;
string s;
int n, q;
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cin >> n >> q;
  cin >> s;
  int ml = 0;
  int mr = n - 1;
  int mml = 0;
  int mmr = n - 1;
  vector<pair<string, string>> vs;
  for (int i = 0; i < q; i++) {
    string t, d;
    cin >> t >> d;
    vs.emplace_back(t, d);
  }
  reverse(vs.begin(), vs.end());
  for (int i = 0; i < q; i++) {
    string t = vs[i].first;
    string d = vs[i].second;
    if (d == "L" && ml < n && s[ml] == t[0]) ml++;
    if (d == "R" && mr > 0 && s[mr] == t[0]) mr--;
    mml = max(ml, mml);
    mmr = min(mr, mmr);
  }
  cout << n - (mml + (n - 1 - mmr)) << endl;
}
