#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, Q;
  cin >> N >> Q;
  string s;
  cin >> s;
  string t[Q], d[Q];
  for (int i = 0; i < Q; i++) {
    cin >> t[i] >> d[i];
  }
  int G[N];
  int G_tmp[N];
  for (int i = 0; i < N; i++) {
    G[i] = 1;
    G_tmp[i] = 1;
  }
  for (int l = 0; l < Q; l++) {
    for (int i = 0; i < N; i++) {
      if (s[i] == t[l][0] && G_tmp[i] > 0) {
        G[i] = 0;
        if (d[l] == "R" && i != N - 1) G[i + 1] += G_tmp[i];
        if (d[l] == "L" && i != 0) G[i - 1] += G_tmp[i];
      }
    }
    for (int i = 0; i < N; i++) {
      G_tmp[i] = G[i];
    }
  }
  int sum = 0;
  for (int i = 0; i < N; i++) {
    sum += G[i];
  }
  cout << sum << endl;
}
