#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
int max(int a,int b){return (a>b ? a:b);}
int min(int a,int b){return (a<b ? a:b);}
int compare_int(const void *a, const void *b){return *(int*)a - *(int*)b;}
//qsort(配列, 長さ, sizeof(int), compare_int);
double BS(int array[],int len,int target);

//////////////////////////////////////////
int N,Q;
char blank;
char S[200010],t[200010],d[200010];

int zero1(){
    for(int i = 0;i < Q;i++){
        if(d[i]=='L' && t[i]==S[1]) return 1;
    }
    return 0;
}
int nibun1(int n,int M){
    //printf("%d\n",M-n);
    int new = (M+n+1)/2;
    int g = new;
    for(int i = 0;i < Q;i++){
        if(d[i]=='R' && t[i]==S[g] && g>0 && g<N+1)g++;
        if(d[i]=='L' && t[i]==S[g] && g>0 && g<N+1)g--;
    }
    if(g != 0 && M-n <= 1)return n;
    if(g == 0 && M-n <= 1)return M;
    if(g != 0)return nibun1(n,(new+M)/2);
    if(g == 0)return nibun1((n+new+1)/2,M);
}
int zero2(){
    for(int i = 0;i < Q;i++){
        if(d[i]=='R' && t[i]==S[N]) return 1;
    }
    return 0;
}
int nibun2(int n,int M){
    //printf("%d\n",M-n);
    int new = (M+n)/2;
    int g = new;
    for(int i = 0;i < Q;i++){
        if(d[i]=='R' && t[i]==S[g] && g>0 && g<N+1)g++;
        if(d[i]=='L' && t[i]==S[g] && g>0 && g<N+1)g--;
    }
    if(g != N+1 && M-n <= 1)return M;
    if(g == N+1 && M-n <= 1)return n;
    if(g != N+1)return nibun2((n+new+1)/2,M);
    if(g == N+1)return nibun2(n,(new+M)/2);
}

///////////////////////////////////
int main(){
    scanf("%d%d",&N,&Q);
    scanf("%s",S);
    for(int i = 0;i < Q;i++){
        scanf("%c%c%c%c",&blank,&t[i],&blank,&d[i]);
    }
    for(int i = N;i > 0;i--){
        S[i] = S[i-1];
    }


    int count = N;
    if(zero1()){
        count -= nibun1(1,N);
        //printf("%d\n",count);
    }
    if(zero2()){
        count -= N - nibun2(1,N) + 1;
        //printf("%d\n",count);
    }
    printf("%d\n",count);
    return 0;
}


///////////////////////////////////////////


double BS(int array[],int len,int target){ //(配列,長さ,見つける値)
    int low,mid,high;

    low = 0;
    high = len-1;

    int mark;

    while(low <= high){
        mid = (low + high) / 2;
        if(array[mid] == target){
            mark = 0;
            break;
        }else if(array[mid] < target){
            low = mid + 1;
            mark = 1;
        }else{
            high = mid - 1;
            mark = -1;
        }
    }
    if(mark == 0){
        return mid; //配列の何番目か（０から）
    }else if(mark == 1){
        return (double)mid + 0.5;//なかったらどこのあいだか
    }else{
        return (double)mid - 0.5;
    }
}
