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

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