#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <iostream>
#include <bitset>
using namespace std;
#define N 200005
int n,t[N],p[N],Q,ans;char s[N],op[10],tp[10];
int main()
{
	scanf("%d%d%s",&n,&Q,s+1);ans=n;
	for(int i=1;i<=Q;i++)scanf("%s%s",op+1,tp+1),p[i]=op[1],t[i]=tp[1]=='L';
	int l=0,r=n+1;
	for(int i=Q;i;i--)
	{
		if(t[i])
		{
			if(l<=n&&s[l+1]==p[i])l++;
			if(r<=n&&s[r]==p[i])r++;
		}else
		{
			if(l&&s[l]==p[i])l--;
			if(r&&s[r-1]==p[i])r--;
		}
		if(l>=r)return puts("0"),0;
	}
	printf("%d\n",r-l-1);
}