#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

int main()
{
    int n;
    int q;
    char* s;
    long* g;
    
    if(scanf("%d %d", &n, &q) != 2){
        return 0;
    }

    s = calloc(n, sizeof(char)); 
    g = calloc(n, sizeof(long));
    for(int i = 0; i < n ; i++){
        g[i] = 1;
    } 

    if(scanf("%s", s) != 1){
        return 0;
    }
    long* table[26];
    long count[26] = {0};
    for(int i = 0; i < 26; i++){
        table[i] = calloc(n, sizeof(long));
    }

    for(int ch = 'A' ; ch <= 'Z' ; ch++){
        for(int i = 0 ;i < n; i++){
            if(s[i] == ch){
                table[ch - 'A'][count[ch - 'A']] = i;
                count[ch - 'A']++;
            }
        }
    }
    
    long drop = 0;

    for(int magic = 0 ; magic < q ; magic++){
        char ts[2];
        char ds[2];
        if(scanf("%s %s", ts, ds) != 2){
            return 0;
        }

        char t = ts[0];
        char d = ds[0];

        if(d == 'L'){
            for(long ch_pos = 0; ch_pos < count[t - 'A']; ch_pos++){
                long pos = table[t - 'A'][ch_pos];
                if(pos == 0){
                    drop += g[0];
                    g[0] = 0;
                } else {
                    g[pos - 1] += g[pos];
                    g[pos] = 0;
                }
            }
        } else {
            for(long ch_pos = 0; ch_pos < count[t - 'A']; ch_pos++){
                long pos = table[t - 'A'][ch_pos];
                if(pos == (n - 1)){
                    drop += g[n-1];
                    g[n-1] = 0;
                } else {
                    g[pos + 1] += g[pos];
                    g[pos] = 0;
                }
            }
        }
    }

    printf("%ld\n", n - drop);

    free(s);
    free(g);
    for(int i = 0; i < 26; i++){
        free(table[i]);
    }
    return 0;
}


