#![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_variables)]
#[warn(unused_comparisons)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::cmp::{max, min, Ordering};

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")
    };
}

// N M
// input! {
//     N: i32,
//     M: i32,
// }

// N
// a1, ..., aN
// input! {
//     N: i32,
//     A: [i32, N],
// }

// H W
// a11 ... a1W
// ...
// aH1 ... aHW
// input! {
//     H: i32,
//     W: i32,
//     A: [[i32, W], H],
// }

// S
// input! {
//     S: chars,
// }

const MOD: u64 = 1000000007;

fn main() {
    input! {
        N: usize,
        Q: usize,
        S: chars,
        TD: [[char; 2]; Q],
    };

    let mut ok: isize = -1;
    let mut ng: isize = N as isize;

    while ng - ok > 1 {
        let mid: isize = (ok + ng) / 2;
        if isOkLeft(N, &S, mid, &TD) {
            ok = mid;
        } else {
            ng = mid
        }
    }

    let mut ans: isize = ng;
    ok = N as isize;
    ng = -1 as isize;

    while ok - ng > 1 {
        let mid: isize = (ok + ng) / 2;
        if isOkRight(N, &S, mid, &TD) {
            ok = mid;
        } else {
            ng = mid;
        }
    }

    ans += (N as isize) - ok;
    println!("{}", N - (ans as usize));
}

fn isOkLeft(N: usize, S: &Vec<char>, mid: isize, TD: &Vec<Vec<char>>) -> bool {
    let mut now: isize = mid as isize;

    for td in TD.iter() {
        if S[now as usize] == td[0] {
            if td[1] == 'L' {
                now -= 1;
            } else {
                now += 1;
            }
        }

        if now < 0 {
            return true;
        }
    }

    false
}

fn isOkRight(N: usize, S: &Vec<char>, mid: isize, TD: &Vec<Vec<char>>) -> bool {
    let mut now: isize = mid as isize;

    for td in TD.iter() {
        if S[now as usize] == td[0] {
            if td[1] == 'L' {
                now -= 1;
            } else {
                now += 1;
            }
        }

        if (now as usize) >= N {
            return true;
        }
    }

    false
}