#include <stdio.h>
#include <stdlib.h>

int main(void){
	int n, q;
	char *s;
	char *t, *d;
	int l, r;
	scanf("%d %d", &n, &q);
	s = malloc(sizeof(char) * (n + 1));
	scanf("%s", s);
	t = malloc(sizeof(char) * q);
	d = malloc(sizeof(char) * q);
	for(int i = 0; i < q; i++)
		scanf(" %c %c", t + i, d + i);
	l = 0; r = n - 1;
	for(int i = q - 1; i >= 0; i--){
		if(s[l] == t[i] && d[i] == 'L' && l < n)l++;
		if(s[r] == t[i] && d[i] == 'R' && 0 <= r)r--;
	}
	n -= (n - 1 - r);
	n -= l;
	if(n < 0)n = 0;
	printf("%d\n", n);
	return 0;
}
