open Printf
open Scanf

let id x = x
let read_int _ = bscanf Scanning.stdin " %d " id
let read_str _ = bscanf Scanning.stdin " %s " id
let read_pair _ = bscanf Scanning.stdin " %c %c " (fun x y -> (x,y))

let check s m inst dir =
  let n = String.length s in
  let rec check' i = function
    | _ when i = -1 || i = n -> true
    | [] -> false
    | (t,d)::rest ->
      if t = s.[i]
      then check' (if d = dir then i-1 else i+1) rest
      else check' i rest
  in check' m inst

let rec binary_search s l r inst d = match r - l = 1 with
    | true -> l
    | false ->
      let m = (l + r) / 2 in
      let (l',r') = if check s m inst d then (m, r) else (l, m) in
      binary_search s l' r' inst d

let rev_str s =
  let n = String.length s in
  String.init n (fun i -> s.[n-i-1])

let () =
  let n = read_int () in
  let q = read_int () in
  let s = read_str () in
  let inst = Array.(init q read_pair |> to_list) in
  let l = binary_search s (-1) n inst 'L' + 1 in
  let r = binary_search (rev_str s) (-1) n inst 'R' + 1 in
  printf "%d\n" (n - r - l)
