program atgc3
  implicit none
  character(len=10000) :: 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)                                                                                                                                    
     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
     write(*,'(i0)') CountAC
  enddo

  deallocate(LR)



end program atgc3

