#include <bits/stdc++.h>
using namespace std;
int N, Q;
char s[200000 + 1];
int golems[200000];
vector<int> cells[26];
int main(int argc, char **argv) {
  scanf("%d %d", &N, &Q);
  scanf("%s", s);
  for (int i = 0; i < N; ++i) {
    cells[s[i] - 'A'].push_back(i);
    golems[i] = 1;
  }
  for (int k = 0; k < Q; ++k) {
    char t, d;
    cin >> t >> d;
    for (int j = 0; j < cells[t - 'A'].size(); ++j) {
      int index = cells[t - 'A'][j];
      int golem_cnt = golems[index];
      golems[index] = 0;
      if (d == 'L' && index != 0) {
        golems[index - 1] += golem_cnt;
      } else if (d == 'R' && index != N - 1) {
        golems[index + 1] += golem_cnt;
      }
    }
  }
  int res = 0;
  for (int i = 0; i < N; ++i) res += golems[i];
  printf("%d\n", res);
}
