#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, q;
  char s[100010];
  char t[100010];
  char d[100010];
  int left, right;
  int i, j, k, l;
  int flag = 0;
  long long int ans = 0;
  int count = 0;
  int temp = 0;
  int temp1 = 0;
  int temp2 = 0;
  int max = 0;
  int min = 2000000001;
  int len = 0;
  int sum = 0;
  int ok = 0;
  int ng = 0;
  int dummy;
  scanf("%d %d", &n, &q);
  scanf("%s", &s);
  for (i = 0; i < q; i++) {
    scanf("%c", &dummy);
    scanf("%c %c", &t[i], &d[i]);
  }
  ok = -1;
  ng = n;
  while (ng - ok > 1) {
    temp = (ok + ng) / 2;
    temp2 = temp;
    flag = 0;
    for (i = 0; i < q; i++) {
      if (s[temp2] == t[i]) {
        if (d[i] == 'L') {
          temp2--;
        } else {
          temp2++;
        }
      }
      if (temp2 == -1) {
        flag = 1;
        break;
      } else if (temp2 == n) {
        flag = 0;
        break;
      }
    }
    if (flag == 1) {
      ok = temp;
    } else {
      ng = temp;
    }
  }
  ans = ok;
  ok = n;
  ng = -1;
  while (ok - ng > 1) {
    temp = (ok + ng) / 2;
    temp2 = temp;
    flag = 0;
    for (i = 0; i < q; i++) {
      if (s[temp2] == t[i]) {
        if (d[i] == 'L') {
          temp2--;
        } else {
          temp2++;
        }
      }
      if (temp2 == -1) {
        flag = 0;
        break;
      } else if (temp2 == n) {
        flag = 1;
        break;
      }
    }
    if (flag == 1) {
      ok = temp;
    } else {
      ng = temp;
    }
  }
  printf("%d", ok - ans - 1);
  return 0;
}
