#include<bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;
#define F first
#define S second
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long 
#define ld long double
long long const inf = 1e18;
int const mxn = 2e5+10;
 
ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
} 

int mak[mxn];
pair <char,char> ql[mxn];
char now[mxn];
int n,q;
string s;
long long ans;

check (int x, int t){
	now[x]=s[x];
	mak[x]=x;
	for (int i = 0;i<q;i++){
		if (ql[i].F==now[x]){
			if (ql[i].S=='R')
				mak[x]++;
			if (ql[i].S=='L')
				mak[x]--;
			now[x]=s[mak[x]];
			if (mak[x]<0 and t)
				return 0;
			if (mak[x]>n-1 and t)
				return 1;
			if (mak[x]<0 and !t)
				return 1;
			if (mak[x]>n-1 and !t)
				return 0;
		}
	}
	return 0;
}

int main(){
	cin>>n>>q;
	ans=n;
	cin>>s;
	for (int i = 0;i<q;i++){
		char a ,  b;
		cin>>a>>b;
		ql[i]={a,b};
	}
	int l = 0, r = n, mid = 0;
	while (r-l>1){
		mid = (l+r)/2;
		if (check(mid,1))
			r = mid;
		else
			l= mid;
	}
	//cout<<n-r<<" ";
	ans-=(n-r);
	l = 0, r = n, mid = 0;
	while (r-l>1){
		mid = (l+r)/2;
		if (check(mid,0))
			l= mid;
		else
			r= mid;
	}
	ans-=r;
	//cout<<r<<" ";
	cout<<ans;
	
}