#include <bits/stdc++.h>
using namespace std;
const long long int MAXN = 2e5 + 10;
const long long int MINN = 1e5 + 10;
const long long int inf = 1e18 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin.exceptions(cin.failbit);
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  int n, q, fin = 0;
  string s;
  cin >> n >> q >> s;
  int ch[3][26], ans[n];
  for (int i = 0; i < 3; ++i)
    for (int j = 0; j < 26; ++j) ch[i][j] = 0;
  for (int i = 0; i < q; ++i) {
    char t1, t2;
    cin >> t1 >> t2;
    int curr = t1 - 'A';
    int v;
    if (t2 == 'L')
      v = -1;
    else
      v = 1;
    ch[2][curr] += v;
    ch[0][curr] = min(ch[0][curr], ch[2][curr]);
    ch[1][curr] = max(ch[1][curr], ch[2][curr]);
  }
  for (int i = 0; i < n; ++i) {
    int curr = s[i] - 'A';
    if (ch[0][curr] + i < 0 || ch[1][curr] + i >= n)
      ans[i] = 0;
    else
      ans[i] = 1;
    fin += ans[i];
  }
  cout << fin << endl;
  return 0;
}
