#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int N, Q;
  cin >> N >> Q;
  string s;
  cin >> s;
  vector<vector<int>> indices(100);
  for (int i = 0; i < N; ++i) {
    indices[s[i] - 'A'].emplace_back(i);
  }
  vector<ll> golems(N, 1);
  for (int i = 0; i < Q; ++i) {
    char ti, di;
    cin >> ti >> di;
    for (int index : indices[ti - 'A']) {
      if (index == 0 && di == 'L') {
        golems[index] = 0;
        continue;
      }
      if (index == N - 1 && di == 'R') {
        golems[index] = 0;
        continue;
      }
      if (di == 'L') {
        golems[index - 1] += golems[index];
        golems[index] = 0;
      } else {
        golems[index + 1] += golems[index];
        golems[index] = 0;
      }
    }
  }
  ll ans = accumulate(begin(golems), end(golems), (ll)0);
  cout << ans << endl;
  return 0;
}
