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
  do i=1,Q
     read(*,*) LR(:,i)
  enddo
  do i=1,Q
     CountAC=0
!     write(*,*) LR(:,i)                                                                                                                                                                                                          
     if(LR(1,i).eq.LR(2,i)) then
             !write(*,'(i0)') CountAC                                                                                                                                                                                             
     else
        do j=LR(1,i),LR(2,i)-1
!        write(*,*) S(j:j+1)!,j,Q                                                                                                                                                                                                 
           if(S(j:j+1).eq.'AC') then
              CountAC=CountAC+1
           endif
       !                                                                                                                                                                                                                          
        enddo
     endif
     write(*,'(i0)') CountAC
  enddo

  deallocate(LR)



end program atgc3