#include <bits/stdc++.h>
int main() {
  int N;
  int Q;
  char* s;
  char* t;
  char* d;
  std::cin >> N >> Q;
  s = new char[N];
  std::cin >> s;
  t = new char[Q];
  d = new char[Q];
  for (int i = 0; i < Q; i++) std::cin >> t[i] >> d[i];
  int* num_gorem = new int[N + 2];
  for (int i = 0; i < N + 2; i++) num_gorem[i] = 1;
  for (int i = 0; i < Q; i++) {
    for (int j = 0; j < N; j++) {
      if (t[i] == s[j]) {
        if (d[i] == 'L') {
          num_gorem[1 + j - 1] += num_gorem[1 + j];
          num_gorem[1 + j] = 0;
        } else if (d[i] == 'R') {
          num_gorem[1 + j + 1] += num_gorem[1 + j];
          num_gorem[1 + j] = 0;
        }
      }
    }
  }
  int ans = 0;
  for (int i = 1; i < N; i++) {
    ans += num_gorem[i];
  }
  std::cout << ans;
  delete[] s;
  delete[] t;
  delete[] d;
  return 0;
}
