#include <bits/stdc++.h>
using namespace std;

const int N = 200005;

int n, q;
char s[N];
char t[N], d[N];

int fall(int x) {
  for (int i=0; i<q; i++) {
    if (s[x] == t[i]) {
      if (d[i] == 'L') --x;
      else ++x;
    }
    
    if (x < 0) return -1;
    if (x >= n) return 1;
  }
  
  return 0;
}

int main() {
  scanf("%d %d", &n, &q);
  scanf("%s", s);
  
  for (int i=0; i<q; i++) {
    getchar();
    scanf("%c %c", t + i, d + i);
  }
  
  int l = 0, r = n-1;
  int ansL = -1;
  while (l <= r) {
    int mid = l + r >> 1;
  
    if (fall(mid) == -1) {
      ansL = mid;
      l = mid + 1;
    } else r = mid - 1;
  }
  
  int ansR = n;
  l = 0, r = n-1;
  while (l <= r) {
    int mid = l + r >> 1;
    
    if (fall(mid) == 1) {
      ansR = mid;
      r = mid - 1;
    } else l = mid + 1;
  }
  
  printf("%d\n", n - min(n, (ansL+1) + (n-ansR)));
  return 0;
}
