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