#include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)

int n,q;
char s[252521];
char t[252521], d[252521];

int main(){
	scanf("%d%d",&n,&q);
	scanf("%s",s);
	REP(i,q)scanf("%s%s",t+i,d+i);
	int rp, lp;
	int ok = -1, ng = n;
	while(abs(ok-ng)>1){
		int x = (ok+ng)/2;
		bool right = false;
		int p = x;
		REP(i,q)if(s[p]==t[i]){
			p += d[i]=='R' ? +1 : -1;
			if(p==n){
				right = true;
				break;
			}
		}
		if(right){
			ng = x;
		}else{
			ok = x;
		}
	}
	rp = ok;
	ok = n, ng = -1;
	while(abs(ok-ng)>1){
		int x = (ok+ng)/2;
		bool left = false;
		int p = x;
		REP(i,q)if(s[p]==t[i]){
			p += d[i]=='R' ? +1 : -1;
			if(p==-1){
				left = true;
				break;
			}
		}
		if(left){
			ng = x;
		}else{
			ok = x;
		}
	}
	lp = ok;
	printf("%d\n",rp-lp+1);
	return 0;
}