PROGRAM ATCODER

implicit none
integer :: n,q,i,c_l=1,c_r=1
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
    if ( s(c_l:c_l) == t(i) ) then
      c_l = c_l + 1
    else if ( s(n+2-c_r:n+2-c_r) == t(i) .and. n+2-c_r<=n ) then
      c_r = c_r - 1
    end if
  else if ( d(i) == 'R' ) then
    if ( s(n+1-c_r:n+1-c_r) == t(i) ) then
      c_r = c_r + 1
    else if ( s(c_l-1:c_l-1) == t(i) .and. c_l-1>=1) then
      c_l = c_l - 1
    end if
  end if
end do

if ( n-(c_l-1)-(c_r-1) < 0 ) then
  print'(i0)',  0
  stop
end if

print'(i0)', n-(c_l-1)-(c_r-1)

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

END PROGRAM ATCODER
