use std::io::BufRead;

pub struct StdinReader<R: BufRead> {
    pub buf_reader: R,
    pub buf: String,
}

impl<R: BufRead> StdinReader<R> {
    pub fn new(r: R) -> Self {
        StdinReader {
            buf_reader: r,
            buf: String::with_capacity(10000),
        }
    }
}

#[macro_export]
macro_rules! input {
    ($reader : expr, $t : ty) => { // one variable
        match &mut $reader {
            reader => {
                use std::io::BufRead;
                reader.buf_reader.read_line(&mut reader.buf).unwrap();
                let tmp_var: $t = reader.buf.trim().parse().unwrap();
                reader.buf.clear();
                tmp_var
            },
        }
    };
    ($reader : expr, $t0 : ty, $t1 : ty) => { // 2 tuple
        match &mut $reader {
            reader => {
                use std::io::BufRead;
                reader.buf_reader.read_line(&mut reader.buf).unwrap();
                let tmp_var: Vec<$t0> = reader.buf.trim().split_whitespace().map(|a| a.parse().unwrap()).collect();
                reader.buf.clear();
                (tmp_var[0].clone(), tmp_var[1].clone())
            }
        }
    };
    ($reader : expr, $t0 : ty, $t1 : ty, $t2 : ty) => { // 3 tuple
        match &mut $reader {
            reader => {
                use std::io::BufRead;
                reader.buf_reader.read_line(&mut reader.buf).unwrap();
                let tmp_var: Vec<$t0> = reader.buf.trim().split_whitespace().map(|a| a.parse().unwrap()).collect();
                reader.buf.clear();
                (tmp_var[0].clone(), tmp_var[1].clone(), tmp_var[2].clone())
            }
        }
    };
    ($reader : expr, $t : ty; $size : expr) => { // Vector
        match &mut $reader {
            reader => {
                use std::io::BufRead;
                reader.buf_reader.read_line(&mut reader.buf).unwrap();
                let tmp_var: $t = reader.buf.trim().split_whitespace().map(|a| a.parse().unwrap()).collect();
                reader.buf.clear();
                tmp_var
            }
        }
    };
}

fn main() {
    solve_c();
}

fn solve_c() {
    let handle = std::io::stdin();
    let mut r = StdinReader::new(handle.lock());
    let (n, q): (usize, usize) = input!(r, usize, usize);
    let s: String = input!(r, String);
    use std::collections::HashMap;
    let mut hm: HashMap<char, Vec<usize>> = HashMap::with_capacity(27);
    for (idx, c) in s.char_indices() {
        let mut en = hm.entry(c).or_insert(vec![]);
        en.push(idx);
    }
    let mut gorems: Vec<usize> = vec![1; n];
    for _ in 0..q {
        let (c, dir): (String, String) = input!(r, String, String);
        let (c, dir): (char, char) = (c.chars().nth(0).unwrap(), dir.chars().nth(0).unwrap());
        let tiles: &Vec<usize> = hm.get(&c).unwrap();
        let moved_gorems: Vec<(usize, usize)> = tiles.iter().map(|&i| (i, gorems[i])).collect();
        for m in &moved_gorems {
            gorems[m.0] = 0;
        }
        if dir == 'L' {
            for m in moved_gorems {
                if m.0 == 0 {
                    continue;
                }
                gorems[m.0 - 1] += m.1;
            }
        } else if dir == 'R' {
            for m in moved_gorems {
                if m.0 == n - 1 {
                    continue;
                }
                gorems[m.0 + 1] += m.1;
            }
        }
    }
    println!("{}", gorems.into_iter().sum::<usize>());
}

fn solve_b() {
    let handle = std::io::stdin();
    let mut r = StdinReader::new(handle.lock());
    let n: usize = input!(r, usize);
    let s: String = input!(r, String);
    let mut blue = 0;
    let mut red = 0;
    for c in s.chars() {
        if c == 'R' {
            red += 1;
        } else if c == 'B' {
            blue += 1;
        } else {
            panic!("wtf");
        }
    }
    if red > blue {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn solve_a() {
    let handle = std::io::stdin();
    let mut r = StdinReader::new(handle.lock());
    let (a, b, c) = input!(r, usize, usize, usize);
    if (a == b && a == c) {
        println!("Yes");
    } else {
        println!("No");
    }
}
