#include <stdio.h>
int main(void){
    int n,q,i,j,sum;
    int date[200001];
    char s[200001];
    char c[64];
    char c2[64];
    scanf("%d",&n);
    scanf("%d",&q);
    scanf("%s",s);
    sum = 0;
    // すべての場所に1を格納
    for (i = 0; i < n; i++){
        date[i] = 1;
    }
    
    for (i = 0; i < q; i++ ){
        scanf("%s",c);
        scanf("%s",c2);
        j = 0;
        while(1){
            if (s[j] == '\0'){
                break;
            }
            if (s[j] == c[0]){
                if (c2[0] == 'L' && j > 0){
                    date[j - 1] = date[j - 1] +  date[j];
                    date[j] = 0;
                }else if (c2[0] == 'L' && j == 0){
                    date[j] = 0;
                }else if (c2[0] == 'R' && j < n){
                    date[j + 1] = date[j + 1] +  date[j];
                    date[j] = 0;
                }else if (c2 == 'R' && j == n){
                    date[j] = 0;
                }
            }
            j++;
        }
       
    }
   
       // すべての場所に1を格納
    for (i = 0; i < n; i++){
        sum = sum + date[i]; 
    }
    printf("%d",sum);
}
