#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, Q;
  string S;
  cin >> N >> Q;
  cin >> S;
  int golem[N];
  for (int i = 0; i <= N + 1; i++) {
    golem[i] = 1;
  }
  golem[0] = 0;
  golem[N + 1] = 0;
  for (int i = 0; i < Q; i++) {
    char letter, way;
    cin >> letter >> way;
    if (way == 'L') {
      for (int j = 1; j <= N; j++) {
        if (S[j - 1] == letter) {
          golem[j - 1] += golem[j];
          golem[j] = 0;
        }
      }
    } else {
      for (int j = N; j >= 1; j--) {
        if (S[j - 1] == letter) {
          golem[j + 1] += golem[j];
          golem[j] = 0;
        }
      }
    }
    golem[0] = 0;
    golem[N + 1] = 0;
  }
  int sum = 0;
  for (int i = 1; i <= N; i++) {
    sum += golem[i];
  }
  cout << sum;
  return 0;
}
