#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<pair<char, int>> v;
  vector<bool> app(26, false);
  char a, b;
  for (int i = 0; i <= q - 1; i++) {
    cin >> a >> b;
    if (b == 'R')
      v.emplace_back(a, 1);
    else
      v.emplace_back(a, -1);
    app[a - 'A'] = true;
  }
  int cnt = 0;
  for (int ind = 0; ind <= n - 1; ind++) {
    int now = ind;
    for (auto i : v) {
      if (!app[s[now] - 'A']) break;
      if (i.first == s[now]) now += i.second;
      if (now < 0 || now >= n) {
        cnt++;
        break;
      }
    }
  }
  cout << n - cnt << "\n";
  return 0;
}
