#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

typedef long long LL;

const int maxn=2e5+5;

int n,m,dr[maxn];
char s[maxn],index[maxn];

char Read()
{
	char ch=getchar();
	while (ch<'A' || ch>'Z') ch=getchar();
	return ch;
}

int main()
{
	scanf("%d %d",&n,&m);
	scanf("%s",s+1);
	fo(i,1,m)
	{
		char ch1=Read(),ch2=Read();
		index[i]=ch1;
		dr[i]=(ch2=='R');
	}
	
	int ans=0, l=1, r=n;
	fd(i,m,1)
	{
		if (s[l]==index[i] && dr[i]==0) l++, ans++;
		if (s[r]==index[i] && dr[i]==1) r--, ans++;
	}
	
	printf("%d\n",n-ans);
}