#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int N,Q;
string s;
char t[200020],d[200020];

bool judge(int mid,int x){
  int now=mid-1;
  for(int i=0;i<Q;i++){
    if(s[now]==t[i]){
      if(d[i]=='L') now=now-1;
      else now=now+1;
    }
    if(now==x) return true;
    else if(x==N&&now==-1) return false;
    else if(x==-1&&now==N) return false;
  }
  return false;
}

int main(){
  cin>>N>>Q;
  cin>>s;
  for(int i=0;i<Q;i++){
    cin>>t[i]>>d[i];
  }

  int ok=0,ng=N+1;
  while(ng-ok>1){
    int mid=(ok+ng)/2;
    if(judge(mid,-1)) ok=mid;
    else ng=mid;
  }
  int ans=ok;

  ok=N+1;
  ng=0;
  while(ok-ng>1){
    int mid=(ok+ng)/2;
    if(judge(mid,N)) ok=mid;
    else ng=mid;
  }

  cout<<N-min(ans+N-ok+1,N)<<endl;

  return 0;
}
