#include <bits/stdc++.h>
using namespace std;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
const int ddy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
const int inf = 99999999;
const long long linf = 1LL << 62;
long long gcd(long long a, long long b) {
  if (a < b) swap(a, b);
  if (a % b != 0) gcd(b, a % b);
  return b;
}
long long lcm(long long a, long long b) {
  if (a < b) swap(a, b);
  return (a / gcd(a, b)) * b;
}
int main() {
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<char> vr, vl;
  for (int i = 0; i < q; i++) {
    char c, d;
    cin >> c >> d;
    if (d == 'L')
      vl.push_back(c);
    else
      vr.push_back(c);
  }
  int ans = n;
  int pos = 0;
  for (int i = vl.size() - 1; i >= 0; i--) {
    if (s[pos] == vl[i]) pos++;
  }
  ans -= pos;
  pos = n - 1;
  for (int i = vr.size() - 1; i >= 0; i--) {
    if (s[pos] == vr[i]) pos--;
  }
  ans -= (n - 1) - pos;
  cout << max(ans, 0) << endl;
  return 0;
}
