program C2019
  implicit none
  integer N,Q,i,j,alive,location(2 * 10 ** 5),loci
  character(1) ti, di
  character(2 * 10 ** 5) S
  read(*, *) N, Q
  read(*, *) S
  alive = N
  location = 0
  location(1:N) = 1
  
  do i = 1, Q
    read(*, *) ti, di
    do j = 1, N
      if (S(j:j) == ti) then
        loci = location(j)
        location(j) = 0
        if (di == 'L') then
          if (j == 1) then
            alive = alive - loci
          else
            location(j-1:j-1) = location(j-1:j-1) + loci
          end if
        else
          if (j == N) then
            alive = alive - loci
          else
            location(j+1:j+1) = location(j+1:j+1) + loci
          end if
        end if
      end if
    end do
  end do
  write(*, '(i0)') alive
end program C2019