#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 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'){
            if(s[0] == t){
                drop += g[0];
                g[0] = 0;
            }
            for(int pos = 1 ; pos < n ; pos++){
                if(s[pos] == t){
                    g[pos - 1] += g[pos];
                    g[pos] = 0;
                }
            }
        } else {
            if(s[n - 1] == t){
                drop += g[n - 1];
                g[n - 1] = 0;
            }
            for(int pos = n - 2 ; pos >= 0 ; pos--){
                if(s[pos] == t){
                    g[pos + 1] += g[pos];
                    g[pos] = 0;
                }
            }
        }
    }

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

    return 0;
}


