#include <bits/stdc++.h>
using namespace std;
typedef struct block {
  int golem_num;
  char word;
} Block;
typedef struct magic {
  char word;
  char LR;
} Magic;
int main() {
  int N, Q;
  string s;
  cin >> N;
  cin >> Q;
  cin >> s;
  Block block[N];
  for (int i = 0; i < N; i++) {
    block[i].golem_num = 1;
    block[i].word = s[i];
  }
  Magic magic[Q];
  for (int q = 0; q < Q; q++) {
    cin >> magic[q].word;
    cin >> magic[q].LR;
  }
  for (int q = 0; q < Q; q++) {
    char word = magic[q].word;
    char LR = magic[q].LR;
    if (LR == 'L') {
      for (int i = 0; i < N; i++) {
        if (block[i].word == word) {
          if (i == 0) {
            block[i].golem_num = 0;
          } else {
            block[i - 1].golem_num += block[i].golem_num;
            block[i].golem_num = 0;
          }
        }
      }
    } else {
      for (int i = N - 1; i > -1; i--) {
        if (block[i].word == word) {
          if (i == N - 1) {
            block[i].golem_num = 0;
          } else {
            block[i + 1].golem_num += block[i].golem_num;
            block[i].golem_num = 0;
          }
        }
      }
    }
  }
  int sum = 0;
  for (int i = 0; i < N; i++) {
    sum += block[i].golem_num;
  }
  cout << sum << endl;
  return 0;
}
