"use strict";
function Main(input) {
    let lines = input.split("\n");
    let NQ = lines.shift().trim().split(/\s/).map((v) => v - 0);
    let N = NQ[0], Q = NQ[1];
    let S = lines.shift().trim().split('');
    let Ss = {};
    S.forEach((v, i) => {
        let a = Ss[v] || [];
        a.push(i);
        Ss[v] = a;
    })
    let s = new Array(N).fill(1);
    let TD = new Array(Q);
    for (let n = 0; n < Q; n++) {
        let td = lines.shift().trim().split(/\s/);
        let ch = td[0];
        let dir = td[1];
        let a = Ss[ch] || []; 
        for (let p = 0; p < a.length; p++) {
            let m = a[p];
            let k = s[m]; s[m] = 0;
            if (dir == 'L' && m > 0) s[m-1] += k;
            if (dir == 'R' && m < N-1) s[m+1] += k;
        }
    }
    let ans = s.reduce((ac, v) => ac + v, 0);
    console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
