program main
implicit none
integer :: n,q,l,r
character(len=10*5) :: s
integer :: i,j,nc

read(*,*) n,q
read(*,*) s(1:n)
do i = 1, q
   read(*,*) l,r
   
   nc = 0
   do j = l, r-1
      if (s(j:j+1) =='AC')then
         nc = nc+1
      end if
   end do
   write(*,'(i0)') nc

end do



end program main
