// Try Exawizards 2019
// author: Leonardone @ NEETSDKASU

fn main() {
	let mut stdin = String::new();
    std::io::Read::read_to_string(
    	&mut std::io::stdin(),
        &mut stdin).unwrap();
	let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
    	($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    // TLE Answer
    
    let n = get!(usize);
    let q = get!(usize);
    let s = get().as_bytes();
    let mut ps = vec![vec![]; 26];
    for i in 0..n {
    	let p = (s[i] - b'A') as usize;
        ps[p].push(i);
    }
    let mut sum = vec![1; n];
    for _ in 0..q {
    	let t = get().as_bytes()[0];
    	let d = get().as_bytes()[0];
        let p = (t - b'A') as usize;
        let c = ps[p].len();
        let mut tmp = vec![];
        for i in 0..c {
        	let j = ps[p][i];
            let w = sum[j];
            sum[j] = 0;
            if d == b'L' {
            	if j > 0 {
                	let u = (s[j-1] - b'A') as usize;
                    if u == p {
                    	tmp.push((j-1, w));
                    } else {
                    	sum[j-1] += w;
                    }
                }
            } else {
            	if j + 1 < n {
                	let u = (s[j+1] - b'A') as usize;
                    if u == p {
                    	tmp.push((j+1,w));
                    } else {
                    	sum[j+1] += w;
                    }
                }
            }
        }
        for &(t, w) in tmp.iter() {
        	sum[t] += w;
        }
    }
    let ans = sum
    	.iter()
        .sum::<i64>();
	println!("{}", ans);
}