#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define N 200010
ll n,q;
string s;
char t[N],d[N];
int solt(ll x){
    for(int i=0;i<q;i++){
	if(s[x]==t[i]){
	    if(d[i]=='L')x--;
	    if(d[i]=='R')x++;
	}
	if(x==-1)return 1;
	if(x==n)return 2;
    }
    return 0;
}
int main(){
    cin>>n>>q>>s;
    for(int i=0;i<q;i++){
	cin>>t[i]>>d[i];
    }
    //for(int i=0;i<n;i++)cout<<solt(i)<<" ";cout<<endl;
    ll mid;
    ll ls=-1,rs=n;
    while(ls<rs-1){
	mid=(ls+rs)/2;
	if(solt(mid)==1)ls=mid;
	else rs=mid;
    }
    ll lt=-1,rt=n;
    while(lt<rt-1){
	mid=(lt+rt)/2;
	if(solt(mid)==2)rt=mid;
	else lt=mid;
    }
    //cout<<rt<<" "<<ls<<endl;
    cout<<rt-ls-1<<endl;
    return 0;
}
