use std::collections::HashMap;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize1,
        q: usize,
        s: chars,
        td: [(String, String); q]
    };
    let mut hmap: HashMap<char, Vec<usize>> = HashMap::new();
    for &c in s.iter() {
        hmap.insert(c, vec![]);
    }
    for (i, &c) in s.iter().enumerate() {
        let vv = hmap.get_mut(&c).unwrap();
        vv.push(i);
    }

    for (t, d) in td {
        let t = t.chars().next().unwrap();
        let d = d.chars().next().unwrap();
        let vv = hmap.get(&t).unwrap_or(&vec![]).clone();
        let mut newv = vec![];
        for &i in vv.iter() {
            if d == 'L' {
                if i == 0 {
                    continue;
                }
                if s[i - 1] == t {
                    newv.push(i - 1);
                } else {
                    hmap.get_mut(&s[i - 1]).unwrap().push(i - 1);
                }
            } else {
                if i >= n {
                    continue;
                }
                if s[i + 1] == t {
                    newv.push(i + 1);
                } else {
                    hmap.get_mut(&s[i + 1]).unwrap().push(i + 1);
                }
            }
        }
        hmap.insert(t, newv);

        println!("{:?}", hmap);
    }
    let result = hmap.iter().fold(0, |sum, (_, v)| sum + v.len());
    println!("{}", result);
}
