program main
implicit none
integer :: n, q, i, j, res
integer , allocatable :: g(:)
character :: s*200000, t*1, d*1

read(*,*) n, q
allocate( g(N) )
g = 1
read(*,*) s(1:n)

res = 0
do i = 1, q
   read(*,*) t, d
   do j = 1, n
      if(s(j:j) == t ) then
         if( d=='R' ) then
            if( j==n ) then
               res = res + g(j)
            else
               g(j+1) = g(j+1) + g(j)
            end if
         else
            if ( j== 1 ) then
               res = res + g(j)
            else
               g(j-1) = g(j-1) + g(j)
            end if
         end if
         g(j) = 0
      end if
   end do
end do
write(*,'(i0)') n-res

         

end program main
