#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(lli i=a;i<b;i++)
#define initialize(array,size,value) for(lli i=0;i<size;i++) array[i]=value
#define couta(array,size) for(lli i=0;i<size;i++) cout<<array[i]<<" "
#define vl vector<lli>
#define vp vector< pair <lli,lli> >
#define sl set<lli>
#define msp multiset < pair < long long , long long > > S;
#define pll pair<lli, lli>
#define mll map<lli, lli>            //for( map<lli, lli>::iterator i=temp.begin();i!=temp.end();i++)cout<<i->fi<<" "<<i->se<<endl;
#define mvl map<lli, vl>
#define umll unordered_map<lli, lli>
#define vt vector<pair<lli, pll >  >
#define vf vector<pair<pll,pll > >
#define qu queue<lli>
#define pq priority_queue<lli>
#define dq deque <lli>
#define ptr vector<lli>::iterator
#define bs(array,x) binary_search(array.begin(),array.end(),x) // also valid for set and multiset
#define lb(array,x) lower_bound(array.begin(),array.end(),x)
#define ub(array,x) upper_bound(array.begin(),array.end(),x)
#define nobw(array,i,j) upper_bound(array.begin(), array.end(), j)-lower_bound(array.begin(), array.end(), i) //number of numbers between i & j
#define vc clear()
#define endl '\n'
#define sp system("pause");
#define INF 9223372036854775807
#define MINF -9223372036854775808
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
int main()
{
 //	ios::sync_with_stdio(0);
 //   cin.tie(0);
    lli n,q;
    cin>>n>>q;
    string s;
    cin>>s;
    lli temp[n];initialize(temp,n,1);
    vl lft[26],rt[26],pos[26];
    for(lli i=1;i<n;i++)lft[s[i]-'A'].pb(s[i-1]-'A');
    for(lli i=0;i<n;i++)rt[s[i]-'A'].pb(s[i+1]-'A');
    for(lli i=0;i<n;i++)pos[s[i]-'A'].pb(i);
   // couta(temp,n);
    for(lli i1=0;i1<q;i1++){
    	char a,b;
    	cin>>a>>b;
    	for(lli i=0;i<pos[a-'A'].size();i++){
    		if(temp[pos[a-'A'][i]]==0)continue;
    		if(b=='L'){
    			if(pos[a-'A'][i]==0){temp[0]=0;continue;}
    			else {lli x=temp[pos[a-'A'][i]];temp[pos[a-'A'][i]-1]+=x;temp[pos[a-'A'][i]]=0;}
			}
    		if(b=='R'){
    			if(pos[a-'A'][i]==n-1){temp[n-1]=0;continue;}
    			else {lli x=temp[pos[a-'A'][i]];temp[pos[a-'A'][i]+1]+=x;temp[pos[a-'A'][i]]=0;}
			}
    	}
    //	couta(temp,n);cout<<endl;
	}
	lli ans=0;
    for(lli i=0;i<n;i++)ans+=temp[i];
    cout<<ans;
    return 0;
}
