#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const int inf = 2e9;
const long long int INF = 1e18;
int main() {
  int n, m;
  cin >> n >> m;
  string s;
  cin >> s;
  vector<string> a(m), b(m);
  string l, r;
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i];
    if (b[i] == "L")
      l += a[i];
    else
      r += a[i];
  }
  string lrev = l, rrev = r;
  for (int i = 0; i < l.size(); i++) {
    lrev[i] = l[l.size() - i - 1];
  }
  for (int i = 0; i < r.size(); i++) {
    rrev[i] = r[r.size() - i - 1];
  }
  int lite = 0, rite = 0;
  int lmax = 0, rmax = 0;
  for (int i = 0; i < l.size(); i++) {
    if (lrev[i] == s[lite]) {
      lite++;
      lmax++;
    }
  }
  for (int i = 0; i < r.size(); i++) {
    if (rrev[i] == s[n - rite - 1]) {
      rite++;
      rmax++;
    }
  }
  cout << n - (lmax + rmax) << endl;
  return 0;
}
