#include<bits/stdc++.h>
#define ll long long
#define N 200010
using namespace std;
char get(){
	char ch=getchar();
	while (ch<'A'||ch>'Z') ch=getchar();
	return ch;
}
int n,q;
char ch[N];
struct Info{char x,y;}qu[N];
int main(){
	cin>>n>>q;
	for (int i=1;i<=n;i++)ch[i]=get();
	for (int i=1;i<=q;i++){qu[i].x=get();qu[i].y=get();}
	int l=1,r=n;
	for (int i=q;i>=1;i--){
		if (qu[i].y=='L'){
			if (ch[l]==qu[i].x) l++;
			if (r!=n&&ch[r+1]==qu[i].x) r++;
		}else{
			if (ch[r]==qu[i].x) r--;
			if (l!=1&&ch[l-1]==qu[i].x) l--;
		}
	}
	cout<<r-l+1<<endl;
	return 0;
}