implicit none
integer n,q,i,j,tmp,k
character(:),allocatable:: s,lab
character(1) t,d
integer,allocatable,dimension(:)::pos
integer:: counts

read(5,*)n,q
allocate(character(n)::s)
allocate(character(n)::lab)
allocate(pos(n))

do k=1,n
pos(k)=k
enddo

read(5,*)s
lab=s
counts=n

do i=1,q
read(5,*)t,d

do j=1,n

if(lab(j:j)==t(1:1) .and. d(1:1)=="L") then 
pos(j)=pos(j)-1
tmp=pos(j)

if(n .ge. tmp .and. tmp.ge.1) then
lab(j:j)=s(tmp:tmp)
else
lab(j:j)="0"
counts=counts-1
endif

else if(lab(j:j)==t(1:1) .and. d(1:1)=="R")then
pos(j)=pos(j)+1
tmp=pos(j)

if(n .ge. tmp .and. tmp.ge.1) then
lab(j:j)=s(tmp:tmp)
else
lab(j:j)="0"
counts=counts-1
endif

endif


enddo

enddo



write(6,*)counts



deallocate(s)
deallocate(lab)
deallocate(pos)

end