program atgc3
  implicit none
  character(len=100000) :: S
  integer :: i,j,N,Q,CountAC
  integer,allocatable :: LR(:,:)
  read(*,*) N,Q
  allocate(LR(2,Q))
  read(*,*) S
  !write(*,*) trim(S)                                                                                                                                                                                                             
  do i=1,Q
     read(*,*) LR(:,i)
     CountAC=0
!     write(*,*) LR(:,i)                                                                                                                                                                                                          
!     if(LR(1,i).eq.LR(2,i)) then                                                                                                                                                                                                 
!     else                                                                                                                                                                                                                        
      do j=LR(1,i),LR(2,i)-1
        if(S(j:j+1).eq.'AC') then
           CountAC=CountAC+1
        endif
       !                                                                                                                                                                                                                          
      enddo
!     endif                                                                                                                                                                                                                       
      write(*,'(i0)') CountAC
  enddo

  deallocate(LR)



end program atgc3


