#include <bits/stdc++.h>
int check(char *str, int n, char *t, char *d, int q, int cur) {
  int i;
  if (cur == -1 || cur == n) {
    return cur;
  }
  for (i = 0; i < q; ++i) {
    if (t[i] == str[cur]) {
      if (d[i] == 'R') {
        ++cur;
      } else {
        --cur;
      }
      if (cur == -1 || cur == n) {
        break;
      }
    }
  }
  return cur;
}
void solve(char *str, int n, char *t, char *d, int q) {
  int cur1, cur2, cur;
  cur1 = cur2 = n / 2;
  while ((cur = check(str, n, t, d, q, cur1)) > -1) {
    if (cur1 <= cur) {
      --cur1;
    } else {
      cur1 = --cur;
    }
  }
  while ((cur = check(str, n, t, d, q, cur2)) < n) {
    if (cur <= cur2) {
      ++cur2;
    } else {
      cur2 = ++cur;
    }
  }
  printf("%d\n", cur2 - cur1 - 1);
}
int main(void) {
  int n, q, i;
  scanf("%d %d", &n, &q);
  char *str = (char *)malloc((n + 4) * sizeof(char));
  char *t = (char *)malloc((q + 4) * sizeof(char));
  char *d = (char *)malloc((q + 4) * sizeof(char));
  scanf("%s", str);
  fgetc(stdin);
  for (i = 0; i < q; ++i) {
    scanf("%c %c", &t[i], &d[i]);
    fgetc(stdin);
  }
  solve(str, n, t, d, q);
  return 0;
}
