use std::io::BufRead;
use std::collections::hash_set::Union;
use std::collections::vec_deque::VecDeque;

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

#[derive(Debug)]
pub struct UnionFind {
    parents: Vec<usize>,
    rank: Vec<usize>,
}

impl UnionFind {
    pub fn new(n: usize) -> Self {
        let mut parents: Vec<usize> = Vec::with_capacity(n);
        for i in 0..n {
            parents.push(i);
        }
        let rank = vec![1; n];
        UnionFind {
            parents: parents,
            rank: rank,
        }
    }
    /// root を探す
    pub fn find(&mut self, x: usize) -> usize {
        if self.parents[x] == x {
            x
        } else {
            let par = self.parents[x];
            let root = self.find(par);
            self.parents[x] = root;
            root
        }
    }
    /// union x and y
    /// ルートを付け替えるだけで，新たに付け加えられた木の子供の親は変わらないことに注意
    /// unionしたあとも find を呼ぶ必要がある．
    pub fn union(&mut self, x: usize, y: usize) -> bool {
        let x_root = self.find(x);
        let y_root = self.find(y);
        // if x_root == y_root, do nothing
        if x_root == y_root { return false; }
        if self.rank[x_root] > self.rank[y_root] {
            // x <--- y
            self.parents[y_root] = x_root;
        } else {
            // y <--- x
            self.parents[x_root] = y_root;
            if self.rank[x_root] == self.rank[y_root] {
                self.rank[y_root] += 1;
            }
        }
        return true;
    }
}

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 mut s: VecDeque<char> = input!(r, String).chars().collect();
    let mut magics: Vec<(char, char)> = vec![];
    let mut nf = UnionFind::new(n+2);
    for _ in 0..q {
        let magic: (char, char) = to_char(input!(r, String, String));
        magics.push(magic);
    }
    for m in magics.into_iter().rev() {
        if m.1 == 'L' {
            let mut is_delete = false;
            if let Some(&f) = s.front() {
                if f == m.0 {
                    is_delete = true;
                }
            }
            if is_delete { s.pop_front(); }
        } else if m.1 == 'R' {
            let mut is_delete = false;
            if let Some(&l) = s.back() {
                if l == m.0 {
                    is_delete = true;
                }
            }
            if is_delete { s.pop_back(); }
        }
    }
    println!("{}", s.len());
}

fn to_char(t: (String, String))-> (char, char) {
    (t.0.chars().nth(0).unwrap(), t.1.chars().nth(0).unwrap())
}
