#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn binary_search<F>(lb: i32, ub: i32, criterion: F) -> i32
where
    F: Fn(i32) -> bool,
{
    let mut lb = lb;
    let mut ub = ub;
    while ub - lb > 1 {
        let mid = (ub + lb) / 2;
        if criterion(mid) {
            lb = mid;
        } else {
            ub = mid;
        }
    }
    ub
}

fn criterion_to_right(i: i32, queries: &Vec<(char, char)>, s: &Vec<char>, inversed: bool) -> bool {
    if i >= s.len() as i32 {
        return true;
    }
    if i < 0 {
        return false;
    }
    let mut i = i;
    for &q in queries.iter() {
        if q.0 == s[i as usize] {
            if !inversed {
                if q.1 == 'L' {
                    i -= 1;
                } else {
                    i += 1;
                }
            } else {
                if q.1 == 'R' {
                    i -= 1;
                } else {
                    i += 1;
                }
            }
        }
        if i >= s.len() as i32 {
            return true;
        }
        if i < 0 {
            return false;
        }
    }
    false
}

fn main() {
    let v: Vec<usize> = read_vec();
    let (n, q) = (v[0], v[1]);
    let mut s = read::<String>().chars().collect::<Vec<_>>();

    let mut queries = Vec::new();
    for _ in 0..q {
        let v: Vec<char> = read_vec();
        let (t, d) = (v[0], v[1]);
        // let t = t.to_digit(36).unwrap() as usize - 10;
        queries.push((t, d));
    }

    let r_idx = binary_search(-1, n as i32, |x| {
        !criterion_to_right(x, &queries, &s, false)
    });
    s.reverse();
    let l_idx = binary_search(-1, n as i32, |x| !criterion_to_right(x, &queries, &s, true));

    let mut removed_by_r;
    if r_idx == -1 {
        removed_by_r = 0;
    } else {
        removed_by_r = n - r_idx as usize;
    }

    let mut removed_by_l;
    if l_idx == -1 {
        removed_by_l = 0;
    } else {
        removed_by_l = n - l_idx as usize;
    }
    println!("{}", n - removed_by_r - removed_by_l);
}
