#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N, Q, sum = 0;
  cin >> N >> Q;
  int cnt[N];
  char t[Q], d[Q];
  string s;
  cin >> s;
  for (int i = 0; i < N; i++) cnt[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') {
      for (int j = 0; j < N; j++) {
        if (t[i] == s[j]) {
          if (j == 0)
            cnt[0] = 0;
          else {
            cnt[j - 1] += cnt[j];
            cnt[j] = 0;
          }
        }
      }
    } else {
      for (int j = N - 1; j >= 0; j--) {
        if (t[i] == s[j]) {
          if (j == N - 1)
            cnt[N - 1] = 0;
          else {
            cnt[j + 1] += cnt[j];
            cnt[j] = 0;
          }
        }
      }
    }
  }
  for (int i = 0; i < N; i++) sum += cnt[i];
  cout << sum << endl;
  return 0;
}
