#include <bits/stdc++.h>
int main() {
  int n, q;
  int i, j;
  scanf("%d %d", &n, &q);
  char s[200004];
  scanf("%s", &s);
  char t[200001], d[200001];
  for (i = 0; i < q; i++) {
    scanf("\n%c %c", &t[i], &d[i]);
  }
  int k, cur, flag;
  int left = -1;
  for (k = 0; k < n; k++) {
    cur = k;
    flag = 0;
    for (i = 0; i < q; i++) {
      if (flag == 1) {
        break;
      }
      if (t[i] == s[cur]) {
        switch (d[i]) {
          case 'R':
            if (cur == (n - 1)) {
              flag = 1;
              break;
            }
            cur++;
            break;
          case 'L':
            if (cur == 0) {
              flag = 1;
              left = k;
              break;
            }
            cur--;
            break;
        }
      }
    }
  }
  int right = n;
  for (k = n - 1; k >= 0; k--) {
    cur = k;
    flag = 0;
    for (i = 0; i < q; i++) {
      if (flag == 1) {
        break;
      }
      if (t[i] == s[cur]) {
        switch (d[i]) {
          case 'R':
            if (cur == (n - 1)) {
              right = k;
              flag = 1;
              break;
            }
            cur++;
            break;
          case 'L':
            if (cur == 0) {
              flag = 1;
              break;
            }
            cur--;
            break;
        }
      }
    }
  }
  int ans = n - (left + 1) - (n - right);
  printf("%d", ans);
  return 0;
}
