#include<bits/stdc++.h>
using namespace std;
int main(){
	int N,Q;string s;cin>>N>>Q>>s;
	char T[Q],D[Q];
	for(int i=0;i<Q;i++){
		cin>>T[i]>>D[i];
	}int a=0,b=N+1;int k;
	int c,d;
	while(a+1<b){
		k=(a+b)/2;
		for(int j=0;j<Q;j++){
			if(T[j]==s.at(k-1)){
				if(D[j]=='L'){
					k--;
				}else{
					k++;
				}if(k==0||k==N+1){
                    break;
                }
			}
		}if(k==0){
			a=(a+b)/2;
		}else{
			b=(a+b)/2;
		}
	}c=a;
	a=0;b=N+1;
	while(a+1<b){
		k=(a+b+1)/2;
		for(int j=0;j<Q;j++){
			if(T[j]==s.at(k-1)){
				if(D[j]=='L'){
					k--;
				}else{
					k++;
				}if(k==0||k==N+1){
                    break;
                }
			}
		}if(k==N+1){
			b=(a+b+1)/2;
		}else{
			a=(a+b+1)/2;
		}
	}d=b;
	cout<<d-c-1<<endl;
}