#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, Q;
  cin >> N >> Q;
  string s;
  cin >> s;
  vector<char> t(Q), d(Q);
  vector<vector<int>> ind(Q);
  for (int i = 0; i < Q; i++) {
    cin >> t.at(i);
    cin >> d.at(i);
  }
  vector<int> g(N, 1);
  for (int i = 0; i < Q; i++) {
    string::size_type pos = s.find(t.at(i));
    while (pos != std::string::npos) {
      int temp = g[pos];
      g[pos] = 0;
      if (d[i] == 'R') {
        if (pos < N - 2) g[pos + 1] += temp;
      } else {
        if (pos > 0) g[pos - 1] += temp;
      }
      pos = s.find(t.at(i), pos + 1);
    }
  }
  int cnt = 0;
  for (int i = 0; i < N; i++) {
    cnt += g[i];
  }
  cout << cnt;
  return 0;
}
