#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];
  vector<int> con_pos;
  for (int i = 0; i < N; i++) {
    g_pos[i] = i;
    con_pos.push_back(i);
  }
  for (int i = 0; i < Q; i++) {
    cin >> t >> d;
    auto it = con_pos.begin();
    while (it != con_pos.end()) {
      if (s[g_pos[*it]] == t) {
        g_pos[*it] += ((d == 'L') ? -1 : 1);
      }
      if (g_pos[*it] < 0 || g_pos[*it] > N - 1) {
        con_pos.erase(it);
      } else {
        it++;
      }
    }
  }
  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;
}
