#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N, Q, sum;
  string S;
  char t, d;
  cin >> N >> Q >> S;
  int* G;
  G = new int[N];
  for (int i = 0; i < N; i++) {
    G[i] = 1;
  }
  for (int i = 0; i < Q; i++) {
    cin >> t >> d;
    if (d == 'L') {
      if (S[0] == t) G[0] = 0;
      for (int j = 1; j < N; j++) {
        if (S[j] == t) {
          G[j - 1] += G[j];
          G[j] = 0;
        }
      }
    } else {
      if (S[N - 1] == t) G[N - 1] = 0;
      for (int j = 2; j <= N; j++) {
        if (S[N - j] == t) {
          G[N - j + 1] += G[N - j];
          G[N - j] = 0;
        }
      }
    }
  }
  sum = 0;
  for (int i = 0; i < N; i++) {
    sum += G[i];
  }
  cout << sum << endl;
  return 0;
}
