#include <bits/stdc++.h>
using namespace std;
struct numad {
  long long num;
  vector<vector<long long*>> adress;
};
int main() {
  struct numad alp[26];
  long long N, Q;
  cin >> N >> Q;
  char s[200005];
  cin >> s;
  vector<long long> word(N + 2, 1);
  word[0] = word[N + 1] = 0;
  vector<long long*> x(3, 0);
  for (int i = 1; i <= N; i++) {
    alp[(int)(s[i - 1] - 'A')].num++;
    x[0] = &word[i];
    x[1] = &word[i - 1];
    x[2] = &word[i + 1];
    alp[(int)(s[i - 1] - 'A')].adress.push_back(x);
  }
  char obj, dir;
  int pat;
  for (int i = 0; i < Q; i++) {
    cin >> obj >> dir;
    if (dir == 'L') {
      pat = 1;
    } else {
      pat = 2;
    }
    for (int j = 0; j < alp[(int)(obj - 'A')].num; j++) {
      *alp[(int)(obj - 'A')].adress[j][pat] +=
          *alp[(int)(obj - 'A')].adress[j][0];
      *alp[(int)(obj - 'A')].adress[j][0] = 0;
    }
  }
  cout << N - word[0] - word[N + 1];
}
