#include <bits/stdc++.h>
using namespace std;
void compute(char s[], int count[], char t, char d) {
  int size = sizeof(s) / sizeof(s[0]);
  for (int i = 0; i < size; i++) {
    if (t == s[i]) {
      if ((i == 0 && d == 'L') || (i == size - 1 && d == 'R'))
        count[i] = 0;
      else {
        if (d == 'L') {
          count[i - 1] += count[i];
          count[i] = 0;
        } else {
          count[i + 1] += count[i];
          count[i] = 0;
        }
      }
    }
  }
}
int main() {
  int N, M, sum = 0;
  int count[100010];
  char spell[2];
  char s[100010];
  cin >> N >> M;
  getchar();
  for (int i = 0; i < N; i++) {
    cin >> s[i];
    count[i] = 1;
  }
  getchar();
  for (int j = 0; j < M; j++) {
    cin >> spell[0];
    cin >> spell[1];
    getchar();
    compute(s, count, spell[0], spell[1]);
  }
  for (int i = 0; i < N; i++) {
    sum += count[i];
  }
  cout << sum << endl;
  return 0;
}
