PROGRAM ATCODER

implicit none
integer :: n,q,i,j
character(len=2*10**5) :: s
character(len=1),allocatable :: d(:),t(:)

read*, n,q,s
allocate(t(q),d(q))
do i = 1, q, 1
  read*, t(i),d(i)
end do

print'(i0)', bin_s(1)-bin_s(0)

contains
!!!!!! サブルーチンは↓
logical function isOK(index,key) !indexが条件を満たすかどうか
  implicit none
  integer,intent(in) :: index,key
  if ( check(index) >= key ) then !a(index)がkey以上になる最小のindex
    isOK = .true.
  else
    isOK = .false.
  end if
end function isOK

integer function bin_s(key)
  implicit none
  integer,intent(in) :: key
  integer :: ng,ok,mid
  ng = 0 ; ok = len_trim(s)+1
  do while ( abs(ok-ng) > 1 )
    mid = (ok+ng)/2
    if ( isOK(mid,key) ) then
      ok = mid
    else
      ng = mid
    end if
  end do
  bin_s = ok
end function bin_s

!とある地点(x=start)のゴーレムが落ちるか否か
integer function check(start)
  implicit none
  integer,intent(in) :: start
  integer :: i,x
  x = start
  do i = 1, q, 1
    if ( s(x:x) == t(i) ) then
      if ( d(i) == 'L' ) then
        x = x - 1
      else
        x = x + 1
      end if
    end if
    if ( x == 0 ) then
      check = -1
      return
    else if ( x == n+1 ) then
      check = +1
      return
    end if
  end do
  check = 0
end function

END PROGRAM ATCODER