#include <bits/stdc++.h>
void solve(char *str, int n, char *t, char *d, int q) {
  int cnt1, cnt2, cur, j, max, min;
  cnt1 = 0;
  for (cnt1 = 0; cnt1 < n; ++cnt1) {
    cur = cnt1;
    max = cnt1;
    for (j = 0; j < q; ++j) {
      if (str[cur] == t[j]) {
        if (d[j] == 'R') {
          ++cur;
          if (max < cur) {
            max = cur;
          }
        } else {
          --cur;
        }
        if (cur < 0) {
          break;
        }
      }
    }
    if (cur >= 0) {
      break;
    }
    cnt1 = max;
  }
  for (cnt2 = n - 1; cnt2 > -1; --cnt2) {
    cur = cnt2;
    min = cnt2;
    for (j = 0; j < q; ++j) {
      if (str[cur] == t[j]) {
        if (d[j] == 'R') {
          ++cur;
        } else {
          --cur;
          if (cur < min) {
            min = cur;
          }
        }
        if (cur > n - 1) {
          break;
        }
      }
    }
    if (cur <= n - 1) {
      break;
    }
    cnt2 = min;
  }
  printf("%d\n", cnt2 - cnt1 + 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;
}
