#include <bits/stdc++.h>
using namespace std;
const long long INF = 1000000007;
const int MAX = 210000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
  for (size_t i = 0; i <= n; i++) {
    pr[i] = i;
  }
}
int parent(int x) {
  if (x == pr[x]) return x;
  return pr[x] = parent(pr[x]);
}
bool unit(int x, int y) {
  int px = parent(x);
  int py = parent(y);
  if (px == py) return false;
  if (px < py) {
    pr[py] = px;
  } else {
    pr[px] = py;
  }
  return true;
}
vector<vector<int> > calcNext(const string& S) {
  int n = (int)S.size();
  vector<vector<int> > res(n + 1, vector<int>(26, n));
  for (int i = n - 1; i >= 0; --i) {
    for (int j = 0; j < 26; ++j) res[i][j] = res[i + 1][j];
    res[i][S[i] - 'a'] = i;
  }
  return res;
}
void add(long long& a, long long b) {
  a += b;
  if (a >= MOD) a -= MOD;
}
long long slide(vector<long long>& v, long long a, long long b) {
  long long azv = abs(v[0] - a);
  long long bzv = abs(v[0] - b);
  long long aov = abs(v[1] - a);
  long long bov = abs(v[1] - b);
  v[0] = a;
  v[1] = b;
  return max((azv + bov), (bzv + aov));
}
pair<char, int> qp[200010];
string s;
map<int, int> memo[200010];
int lmemo[200010];
int rmemo[200010];
int n, q;
int check(int ind, int ro) {
  if (ind == -1) return -1;
  if (ind == n) return n;
  if (lmemo[ro] >= ind) return -1;
  if (rmemo[ro] <= ind) return n;
  if (q == ro) return 1;
  if (memo[ind].count(ro)) {
    return memo[ind][ro];
  }
  int& res = memo[ind][ro];
  if (s[ind] == qp[ro].first) {
    res = check(ind + qp[ro].second, ro + 1);
  } else {
    res = check(ind, ro + 1);
  }
  if (res == -1) {
    lmemo[ro] = max(ind, lmemo[ro]);
  }
  if (res == n) {
    rmemo[ro] = min(ind, rmemo[ro]);
  }
  return res;
}
void solv() {
  cin >> n >> q;
  cin >> s;
  int qa[25];
  pair<int, int> la[26];
  pair<int, int> ra[26];
  fill(rmemo, rmemo + 200010, INF);
  fill(lmemo, lmemo + 200010, -1);
  for (size_t i = 0; i < 26; i++) {
    la[i].first = 0;
    la[i].second = 0;
    ra[i].first = n - 1;
    ra[i].second = n - 1;
  }
  for (size_t i = 0; i < q; i++) {
    char d, t;
    cin >> d >> t;
    int p = d - 'A';
    qp[i].first = d;
    qp[i].second = (t == 'L') ? -1 : 1;
  }
  bool bc = false;
  bool ac = false;
  int res = n;
  int fi = 0;
  int ai = n - 1;
  while (fi <= ai) {
    if (!bc && check(fi, 0) == 1) {
      bc = true;
      res -= fi;
    }
    if (fi == ai) break;
    if (!ac && check(ai, 0) == 1) {
      ac = true;
      res -= n - (ai + 1);
    }
    fi++;
    ai--;
  }
  cout << res << endl;
}
int main() {
  solv();
  return 0;
}
