use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
}

macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: ty),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, n: usize, q: usize, s: String, mut td: [(char,char); q]);
    td.reverse();
    let mut s = s.chars().collect::<std::collections::VecDeque<_>>();
    s.push_front('a');
    s.push_back('a');
    let mut l = 0;
    for i in 0..q {
        let (t, d) = td[i];
        if t == s[l] && d == 'R' {
            break;
        }
        if t == s[l + 1] && d == 'L' {
            l += 1;
        }
    }
    let mut r = n + 1;
    for i in 0..q {
        let (t, d) = td[i];
        if t == s[r] && d == 'L' {
            break;
        }
        if t == s[r - 1] && d == 'R' {
            r -= 1;
        }
    }
    println!("{}", r - l - 1);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}
