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

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