program main
  implicit none
  character(len=1),parameter ::alp(26) &
       = (/"A","B","C","D","E","F","G","H","I","J","K","L",&
       "M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"/)
  integer :: N ,Q
  character(len=200000) :: S
  integer,allocatable:: g(:),g_bf(:)
  integer :: out
  logical,allocatable:: flag(:)
  integer :: nalp(26)
  integer :: nchr
  type chr
     integer,allocatable :: ind(:)
  end type chr
  type(chr) :: index_chr(26) ! (:,count(nalp/=0))
  character (len=1),allocatable :: SS(:)
  character (len=1),allocatable :: t(:)
  character (len=1),allocatable :: d(:)
  integer :: ichr
  integer :: i,j,jj
  read(*,*) N,Q
  read(*,'(A)') S(1:N)
  allocate(t(Q),d(Q))
  allocate(g(0:N+1))
  allocate(g_bf(N))
  out=N
  g=1
  do i = 1,Q
     read(*,'(A,1x,A)') t(i),d(i)
  end do
  !
  ! set up allay map
  !
  nalp(:) = 0
  do i = 1,N
     do j = 1,26
        if (alp(j) == S(i:i)) then
           nalp(j) = nalp(j) + 1
           exit
        end if
     end do
  end do
  do i = 1,26
     if (nalp(i) ==0 ) cycle
     allocate( index_chr(i)%ind(nalp(i)) )
     ichr = 0
     do j = 1,N
        if (alp(i) == S(j:j)) then
           ichr = ichr + 1
           index_chr(i)%ind(ichr) = j
        end if
     end do
  end do
  ! main loop
  do i = 1,Q
     g_bf = g(1:N)
     ! get alp
     do jj = 1,26
        if (alp(jj) == t(i)) then
           ichr = jj
           exit
        end if
     end do
     if ( nalp(ichr) == 0 ) cycle ! nothing done
     !
     if (d(i) == 'L') then
        do jj = 1,nalp(ichr)
           j = index_chr(ichr)%ind(jj)
           g(j) = g(j) - g_bf(j)
           g(j-1) = g(j-1) + g_bf(j)
        end do
     else
        do jj = 1,nalp(ichr)
           j = index_chr(ichr)%ind(jj)
           g(j) = g(j) - g_bf(j)
           g(j+1) = g(j+1) + g_bf(j)
        end do
     end if
     !where(g<0) g=0
  end do
  write(*,'(i0)') sum(g(1:N))
  !write(*,'(i0)') out
  stop
end program main
