PROGRAM ATCODER

implicit none
integer :: n,q,out_l=0,out_r=0,i,count,check=1,j
character(len=2*10**5) :: s,s_l='',s_r=''
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

do i = q, 1, -1
    if ( d(i) == 'L' ) then
      s_l = trim(s_l) // t(i)
    else
      s_r = trim(s_r) // t(i)
    end if
end do

count = 1
do i = 1, n, 1
  if ( check == 0 ) exit
  check = 0
  do j = count, len_trim(s_l)
    if ( s(i:i) == s_l(j:j) ) then
      out_l = out_l + 1
      count = j + 1
      check = 1
      exit
    end if
  end do
end do

check = 1
count = 1
do i = n, 1, -1
  if ( check == 0 ) exit
  check = 0
  do j = count, len_trim(s_r)
    if ( s(i:i) == s_r(j:j) ) then
      out_r = out_r + 1
      count = j + 1
      check = 1
      exit
    end if
  end do
end do

print'(i0)', n-out_l-out_r

contains
!!!!!! サブルーチンは↓
!!!!!!

END PROGRAM ATCODER
