use std::io;


fn read_line() -> String {
    let mut line = String::new();

    io::stdin().read_line(&mut line)
        .expect("Failed to read line");
    return line;
}
fn to_i(s: &str) -> i64 {
    return s.trim().parse()
        .expect("Please type a number!");
}
fn str2char(s: &str) -> char {
    let chars: Vec<char> = s.chars().collect();
    chars[0]
}
fn main() {

    let line = read_line();
    let nq: Vec<&str> = line.split(' ').collect();

    let n: usize = to_i(nq[0]) as usize;
    let q: usize = to_i(nq[1]) as usize;

    let s: Vec<char> = read_line().chars().collect();

    let mut tt: Vec<char> = Vec::new();
    let mut dd: Vec<char> = Vec::new();
    for _i in 0..q {
        let l = read_line();
        let td: Vec<&str> = l.split(' ').collect();
        let t: char = str2char(td[0]); 
        let d: char = str2char(td[1]);
        tt.push(t);
        dd.push(d);
    }
    //println!("{:?}", tt);
    //println!("{:?}", dd);

    let mut counts: Vec<i32> = Vec::new();
    for _i in 0..n {
        counts.push(1);
    }


    let mut removed = 0;

    for i in 0..q {
        let t: char = tt[i];
        let d: char = dd[i];
        for j in 0..n {
            if s[j]==t {
                let c = counts[j];
                if d=='L' {
                    //left
                    if j==0{
                        removed += c;
                    }else {
                        counts[j-1] += c;
                    }
                } else {
                    //right
                    if j==n-1 {
                        removed += c;
                    } else{
                        counts[j+1] += c;
                    }
                }
                counts[j] = 0;
            }
        }
        //println!("{:?}", counts);
    }

    print!("{}", n- removed as usize);


    

}   