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

int main(){
	int n, q, i, j, r;
	int **gn;
	//int *gn_new;
	int *p;
	char *str;
	char l,d;
	scanf("%d %d", &n, &q);
	str = (char *)malloc(n+1);
	scanf("%s", str);
	gn = (int *)malloc((q+1) * sizeof(int *));
	for(j=0;j<n;j++) gn[0][j] = 1;
	for(i=0;i<q;i++){
		gn[i+1] = (int *)calloc(n,sizeof(int));
		//p = gn_new;
		scanf("%c", &l); //skip
		if(l != '\n') ungetc(l, stdin);
		scanf("%c %c", &l, &d);
		for(j=0;j<n;j++){
			if(str[j] == l){
				if(d == 'L'){
					if(j > 0) gn[i+1][j-1] += gn[i][j];
				}
				else{
					if(j < n-1) gn[i+1][j+1] += gn[i][j];
				}
			}
			else gn[i+1][j] += gn[i][j];
		}
		free(gn[i]);
	}
	r = 0;
	for(j=0;j<n;j++) r += gn[j];
	printf("%d",r);
	return 0;
}