#include <bits/stdc++.h>

using namespace std;
using nagai = long long;
#define sz(x) int((x).size())

const int N=250250;
char ts[N];
int dir[N];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,q;
	cin>>n>>q;
	string s;
	cin>>s;
	for(int i=0;i<q;++i){
		 char s;
		 char c;
		 cin>>s>>c;
		 ts[i]=s;
		 dir[i]=c=='R'?1:-1;
	}
	int L=-1,R=n;
	while(R-L>1){
		int M=(L+R)/2;
		int cur=M;
		bool ok=false;
		for(int i=0;i<q;++i){
			 if(s[cur]==ts[i])
				 cur+=dir[i];
			 if(cur==n)
				 break;
			 if(cur==-1){
				  ok=true;
				  break;
			 }
		}
		if(ok)L=M;
		else R=M;
	}
	int kek=L;
	L=-1,R=n;
	while(R-L>1){
		int M=(L+R)/2;
		int cur=M;
		bool ok=false;
		for(int i=0;i<q;++i){
			 if(s[cur]==ts[i])
				 cur+=dir[i];
			 if(cur==-1)
				 break;
			 if(cur==n){
				  ok=true;
				  break;
			 }
		}
		if(ok)R=M;
		else L=M;
	}
	if(kek>=R)cout<<0<<'\n';
	else cout<<R-kek-1<<'\n';
	return 0;
}

