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

typedef struct{
	char t[2];
	char d[2];
} magic;

int f,right,left,pright,pleft;

int rchecklife(magic x[],int N,int Q,char ss[],int point){
	int i,maxright=point,maxleft=point,firstpoint=point;
	for(i=0;i<Q;i++){
		if(ss[point]!=x[i].t){
			continue;
		}
		if(x[i].d=='R'){
			point++;
			if(point==N){
				if(right>firstpoint){
					right=firstpoint;
				}
				if((right+left)/2==right){
					printf("0\n");
					exit(0);
				}
				return rchecklife(x,N,Q,ss,(right+left)/2);
			}
		}else{
			point--;
			if(point==0){
				if(left<firstpoint){
					left=firstpoint;
				}
				if((right+left)/2==right){
					printf("0\n");
					exit(0);
				}
				return rchecklife(x,N,Q,ss,(right+left)/2);
			}
		}
	}
	if(f==0){
		pright=firstpoint;
		pleft=firstpoint;
		f=1;
	}
	if(firstpoint<pright){
		pright=firstpoint;
	}
	if(firstpoint>pleft){
		pleft=firstpoint;
	}
	if(pright==right+1 && pleft==left-1){
		return 0;
	}else {
		if(rchecklife(x,N,Q,ss,(pright+right)/2)==0){
			return rchecklife(x,N,Q,ss,(pleft+left)/2);
		}
	}

	


}



int main(){
	int N,Q,i;
	scanf("%d",&N);
	right=N+1;
	pright=N/2;
	pleft=N/2;
	scanf("%d",&Q);
	char ss[200001];
	scanf("%s",ss);

	magic x[200001];

	for(i=0;i<Q;i++){
		scanf("%s",x[i].t);
		scanf("%s",x[i].d);
	}

	i=rchecklife(x,N,Q,ss,N/2);

	printf("%d\n",pright-pleft+1);
	return 0;
}