use std::collections::HashMap;

struct Spell {
    t: char,
    d: char,
}

#[derive(PartialEq, Debug)]
enum GolemStat {
    Alive,
    DeadLeft,
    DeadRight,
}

// Pマス目のゴーレムが生き残るかチェックする。
fn check_golem_stat(
    p: usize,
    n: usize,
    smap: &HashMap<char, Vec<usize>>,
    spells: &Vec<Spell>
) -> GolemStat {
    let mut now_p = p;

    for &Spell{t, d} in spells.iter() {
        if !smap.contains_key(&t) {
            continue;
        }

        for p in smap[&t].iter() {
            if *p != now_p {
                continue;
            }

            if *p == 0 && d == 'L' {
                return GolemStat::DeadLeft;
            }
            if *p == n-1 && d == 'R' {
                return GolemStat::DeadRight;
            }

            now_p = if d == 'L' {*p-1} else {*p+1};

            break;
        }
    }

    GolemStat::Alive
}

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let q: usize = iter.next().unwrap().parse().unwrap();

    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let s = buf.trim().chars().collect::<Vec<char>>();

    let mut smap: HashMap<char, Vec<usize>> = HashMap::new();
    for (i, c) in s.iter().enumerate() {
        if smap.contains_key(c) {
            smap.get_mut(c).unwrap().push(i);
        }
        else {
            smap.insert(*c, vec![i]);
        }
    }

    let mut spells = Vec::new();
    for _ in 0..q {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let mut iter = buf.chars();
        let t: char = iter.next().unwrap();
        let _: char = iter.next().unwrap();
        let d: char = iter.next().unwrap();

        spells.push(Spell{t: t, d: d});
    }

    let mut lb = -1;
    let mut ub = n as isize;
    while ub - lb > 1 {
        let mid = (lb + ub) / 2;
        let stat = check_golem_stat(mid as usize, n, &smap, &spells);
        if stat == GolemStat::DeadLeft {
            lb = mid as isize;
        }
        else {
            ub = mid as isize;
        }
    }
    let dead_left = (lb + 1) as usize;

    let mut lb = -1;
    let mut ub = n as isize;
    while ub - lb > 1 {
        let mid = (lb + ub) / 2;
        let stat = check_golem_stat(mid as usize, n, &smap, &spells);
        if stat == GolemStat::DeadRight {
            ub = mid as isize;
        }
        else {
            lb = mid as isize;
        }
    }
    let dead_right = n - (ub as usize);

    println!("{}", n - dead_left - dead_right);
}
