#include <bits/stdc++.h>
using namespace std;
template <typename Tn>
Tn gcd(Tn a, Tn b) {
  return (b ? gcd(b, a % b) : a);
}
template <typename Tn>
Tn lcm(Tn a, Tn b) {
  return a / gcd(a, b) * b;
}
string IntToString(int number) {
  stringstream ss;
  ss << number;
  return ss.str();
}
int n, q;
string s;
char t[20001];
char d[20001];
int dfs(int level, int s_idx, char dire) {
  if (level < 0 || s_idx < 0 || s_idx >= n) return 0;
  int rec = 0;
  bool did = false;
  bool rec1add = true;
  for (int i = level; i >= 0; i--) {
    if (s[s_idx] == t[i] && dire == d[i]) {
      rec += dfs(i - 1, s_idx + 1, 'L');
      rec += dfs(i - 1, s_idx - 1, 'R');
      did = true;
    } else if (did && s[s_idx] == t[i]) {
      rec1add = false;
    }
  }
  if (did && rec1add) rec++;
  return rec;
}
int main() {
  cin >> n >> q >> s;
  for (int i = 0; i < q; i++) cin >> t[i] >> d[i];
  cout << n - dfs(q - 1, 0, 'L') - dfs(q - 1, n - 1, 'R') << endl;
  return 0;
}
