program main
  implicit none
  integer :: n, q, i, j, num
  integer, allocatable :: box(:)
  character(len=200000) :: s
  character(len=1) :: t, d

  read *, n, q
  read *, s
  allocate (box(n))
  box(:) = 1
 
  do i = 1, q
    read *, t, d
    do j = 1, n
      if (s(j:j) == t) then
        num = box(j)
        box(j) = 0
        if ((j > 1) .and. (d .eq. 'L')) then
          box(j-1) = box(j-1) + num 
        else if ((j < n) .and. (d .eq. 'R')) then
          box(j+1) = box(j+1) + num
        end if
      end if
    end do
  end do

  print '(i0)', sum(box)
end
