#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

int main(){
  
  int n,q;
  cin>>n>>q;
  string s;
  cin>>s;
  char t[q],d[q];
  REP(i,q){
    cin>>t[i]>>q[i];
  }
  int l=0,r=n;
  int left,right;
  bool flag;
  while(r-l>1){
    int m = (l+r)/2;
    int current = m;
    flag = true;//最初にm番目のマスにいたゴーレムが最後まで生き残るか
    REP(i,q){
      if(s[current]==t[i]){
        if(d[i]=='L'){
          current--;
          if(current==0){
            flag = false;
            break;
          }
        }else{
          current++;
          if(current==n){
            flag = false;
            break;
          }
        }
      }
    }
    if(flag){
      r = m+1;
    }else{
      l = m+1;
      if
    }
  }
    
    
  return 0;
}
