#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
char dt[200001][2]={};
int n,q,l,r,tl,tr;string s;
bool ps(int idx,int ck)
{
	int cr = idx;
	for (int i=0;i<q;i++)
	{
		if (cr<0||cr>=n) {break;}
		if (dt[i][0]==s[cr])
		{
			if (dt[i][1]=='L') {cr--;}
			else {cr++;}
		}
	}
	if (ck&&cr<0) {return true;}
	else if (!ck&&cr>=n) {return true;}
	else {return false;}
}
int main()
{
	cin>>n>>q>>s;
	for (int i=0;i<q;i++)
	{
		cin>>dt[i][0]>>dt[i][1];
	}
	l=0,r=n;
	while (l<r)
	{
		int pv = (l+r)>>1;
		if (ps(pv,1)) {l=pv+1;}
		else {r=pv;}
	}
	tl = l;
	l=0;r=n;
	while (l<r)
	{
		int pv = (l+r)>>1;
		if (ps(pv,0)) {r=pv;}
		else {l=pv+1;}
	}
	tr = l;
	//cout<<tl<<" "<<tr<<"\n";
	cout<<tr-tl<<"\n";
	return 0;
}