#include <bits/stdc++.h>
using namespace std;
int S[100010] = {0};
int main() {
  vector<int> table[26];
  int N, Q;
  cin >> N >> Q;
  string s;
  cin >> s;
  for (int i = 0; i < N; i++) {
    S[i] = 1;
    table[s[i] - 'A'].push_back(i);
  }
  char buff[10];
  cin.getline(buff, sizeof(buff));
  for (int i = 0; i < Q; i++) {
    cin.getline(buff, sizeof(buff));
    int idx = buff[0] - 'A';
    for (int j = 0; j < table[idx].size(); j++) {
      if (table[idx][j] == 0) {
        if (buff[2] == 'L') {
          S[table[idx][j]] = 0;
        } else {
          S[table[idx][j] + 1] += S[table[idx][j]];
          S[table[idx][j]] = 0;
        }
      } else if (table[idx][j] == N - 1) {
        if (buff[2] == 'L') {
          S[table[idx][j] - 1] += S[table[idx][j]];
          S[table[idx][j]] = 0;
        } else {
          S[table[idx][j]] = 0;
        }
      } else {
        if (buff[2] == 'L') {
          S[table[idx][j] - 1] += S[table[idx][j]];
          S[table[idx][j]] = 0;
        } else {
          S[table[idx][j] + 1] += S[table[idx][j]];
          S[table[idx][j]] = 0;
        }
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < N; i++)
    if (S[i]) ans += S[i];
  cout << ans << endl;
  return 0;
}
