#include <bits/stdc++.h>
int main(void) {
  int n, q, i, j, sum;
  int date[2000];
  char s[2000];
  char c[16];
  char c2[16];
  scanf("%d", &n);
  scanf("%d", &q);
  scanf("%s", s);
  sum = 0;
  for (i = 0; i < n; i++) {
    date[i] = 1;
    sum++;
  }
  for (i = 0; i < q; i++) {
    scanf("%s", c);
    scanf("%s", c2);
    for (j = 0; j < strlen(s); j++) {
      if (s[j] == c[0]) {
        if (c2[0] == 'L' && j > 0) {
          date[j - 1] = date[j - 1] + date[j];
        } else if (c2[0] == 'L' && j == 0) {
          sum = sum - date[j];
        } else if (c2[0] == 'R' && j == n - 1) {
          sum = sum - date[j];
        } else if (c2[0] == 'R' && j < n) {
          date[j + 1] = date[j + 1] + date[j];
        }
        date[j] = 0;
      }
    }
  }
  printf("%d", sum);
}
