#include <stdio.h>
int main( void )
{
	int N, Q ;
	scanf("%d %d\n", &N, &Q ) ;
	char S[200000+2];
	scanf("%s\n", &S[1] ) ;
	S[0]='\0';
	char t[200000],d[200000];
	for( int n = 0 ; n < Q ; n++ ) {
		scanf("%c %c\n", &t[n], &d[n] ) ;
	}
	int l=0,r=N+1;
	for( int n=Q-1 ; n >= 0 ; n-- ) {
		if( d[n]=='L' ) {
			if( t[n] == S[l+1]) l++ ;
			if( t[n] == S[r]) r++ ;
		} else {
			if( t[n] == S[r-1]) r-- ;
			if( t[n] == S[l]) l-- ;
		}
	}
	int c=r-l-1;
	printf("%d\n", c<0?0:c ) ;
	return 0 ;
}

