#include <bits/stdc++.h>
using namespace std;
int y[200030];
char x[200030];
int n, m;
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    cin >> x[i];
    y[i] = 1;
  }
  char a, b;
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    for (int j = 0; j < n; j++) {
      if (b == 'R') {
        int v = n - 1 - j;
        if (x[v] == a) {
          if (v == (n - 1)) {
            y[v] = 0;
            continue;
          }
          y[v + 1] += y[v];
          y[v] = 0;
        }
      } else if (b == 'L') {
        if (x[j] == a) {
          if (j == 0) {
            y[j] = 0;
            continue;
          }
          y[j - 1] += y[j];
          y[j] = 0;
        }
      }
    }
  }
  int sum = 0;
  for (int i = 0; i < n; i++) {
    sum += y[i];
  }
  printf("%d\n", sum);
  return 0;
}
