#include <bits/stdc++.h>
int main(void) {
  int N, Q;
  int g[200000];
  char s[200000];
  char t, d;
  int tmp[2] = {};
  scanf("%d %d", &N, &Q);
  for (int i = 0; i < N; i++) {
    scanf("%c", &s[i]);
    g[i] = 1;
  }
  int count = N;
  for (int i = 0; i < Q; i++) {
    scanf("%c %c", &t, &d);
    for (int j = 0; j < N; j++) {
      if (t == s[j]) {
        if (d == 'L') {
          if (j == 0) {
            count -= g[j];
            g[j] = 0;
          } else {
            g[j - 1] += g[j];
            g[j] = 0;
          }
        } else {
          if (j == N - 1) {
            count -= g[j];
            g[j] = 0;
          } else {
            g[j + 1] += g[j] - tmp[0];
            tmp[1] = g[j] - tmp[0];
            g[j] = tmp[0];
            tmp[0] = tmp[1];
          }
        }
      } else {
        tmp[0] = 0;
        tmp[1] = 0;
      }
    }
  }
  printf("%d", count);
  return 0;
}
