#include <bits/stdc++.h>
int GetGolemCount(int position, int turn, const int n, const int q,
                  const char s[], const char t[], const char d[], int **dp);
int main() {
  int i, j, n, q, cnt;
  scanf("%d %d", &n, &q);
  char s[n], t[q], d[q];
  int dp[n][q];
  int *dpptr[n];
  for (i = 0; i < n; i++) {
    dpptr[i] = dp[i];
    dp[i][0] = 1;
    for (j = 1; j < q; j++) dp[i][j] = -1;
  }
  scanf("%s", s);
  cnt = n;
  for (i = 0; i < q; i++) {
    scanf("%s %s", &t[i], &d[i]);
  }
  int tmp;
  for (i = 0; i < q; i++) {
    if (d[i] == 'L' && t[i] == s[0]) {
      tmp = GetGolemCount(0, i, n, q, s, t, d, dpptr);
      cnt -= tmp;
    }
    if (d[i] == 'R' && t[i] == s[n - 1]) {
      tmp = GetGolemCount(n - 1, i, n, q, s, t, d, dpptr);
      cnt -= tmp;
    }
  }
  printf("%d", cnt);
  return 0;
}
int GetGolemCount(int position, int turn, const int n, const int q,
                  const char s[], const char t[], const char d[], int **dp) {
  if (turn == 0) {
    return 1;
  } else if (dp[position][turn] != -1) {
    return dp[position][turn];
  } else {
    int cnt = 0;
    if (s[position] != t[turn - 1])
      cnt += GetGolemCount(position, turn - 1, n, q, s, t, d, dp);
    if (position > 0) {
      if (s[position - 1] == t[turn - 1] && d[turn - 1] == 'R')
        cnt += GetGolemCount(position - 1, turn - 1, n, q, s, t, d, dp);
    }
    if (position < n - 1) {
      if (s[position + 1] == t[turn - 1] && d[turn - 1] == 'L')
        cnt += GetGolemCount(position + 1, turn - 1, n, q, s, t, d, dp);
    }
    dp[position][turn] = cnt;
    return cnt;
  }
}
