#include <bits/stdc++.h>
using namespace std;
const int NS = (int)2e5 + 4;
int N, Q;
char arr[NS], mov[NS][4];
int main() {
  scanf("%d %d", &N, &Q);
  scanf("%s", arr + 1);
  for (int i = 1; i <= Q; ++i) scanf(" %c %c", &mov[i][1], &mov[i][2]);
  int ans = N;
  int l = 1, r = N, mid;
  while (l < r) {
    mid = (l + r) / 2 + 1;
    int pos = mid;
    for (int i = 1; i <= Q; ++i)
      if (mov[i][1] == arr[pos]) {
        pos += mov[i][2] == 'L' ? -1 : 1;
        if (!pos) break;
      }
    if (!pos)
      l = mid;
    else
      r = mid - 1;
  }
  if (l == 1 && r == 1) {
    mid = 1;
    int pos = mid;
    for (int i = 1; i <= Q; ++i)
      if (mov[i][1] == arr[pos]) {
        pos += mov[i][2] == 'L' ? -1 : 1;
        if (!pos) break;
      }
    if (pos) r = 0;
  }
  ans -= r;
  l = 1, r = N, mid;
  while (l < r) {
    mid = (l + r) / 2;
    int pos = mid;
    for (int i = 1; i <= Q; ++i)
      if (mov[i][1] == arr[pos]) {
        pos += mov[i][2] == 'L' ? -1 : 1;
        if (pos > N) break;
      }
    if (pos > N)
      r = mid;
    else
      l = mid + 1;
  }
  if (l == N && r == N) {
    mid = 1;
    int pos = mid;
    for (int i = 1; i <= Q; ++i)
      if (mov[i][1] == arr[pos]) {
        pos += mov[i][2] == 'L' ? -1 : 1;
        if (pos > N) break;
      }
    if (pos <= N) l = N + 1;
  }
  ans -= N - l + 1;
  printf("%d\n", ans);
  return 0;
}
