#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
#define pb push_back
#define ft first
#define sd second
#define mp make_pair
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

ll n,q;
char s[200010],t[200010],d[200010];

bool ok(ll m,bool key){
  fr(i,q){
    if(t[i]==s[m]){
      if(d[i]=='L') m--;
      else m++;
      if(m<0) return 1-key;
      if(m>=n) return key;
    }
  }
  return 0;
}

int main(){
  cin>>n>>q;
  ll ans=n;
  fr(i,n) cin>>s[i];
  fr(i,q) cin>>t[i]>>d[i];
  ll l=-1,r=n,m;
  while(r-l>1){
    m=(l+r)/2;
    if(ok(m,0)) l=m;
    else r=m;
  }
  ans-=l+1;
  l=-1;r=n;
  while(r-l>1){
    m=(l+r)/2;
    if(ok(m,1)) r=m;
    else l=m;
  }
  ans-=n-r;
  cout<<ans<<endl;
}