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