implicit none

integer n,q,i,left,right,j,l,r
character(:),allocatable:: s
integer ::counts=0

read(5,*)n,q
allocate(character(n)::s)


read(5,*)s

do i=1,q
read(5,*)l,r
do j=l,r-1

if(s(j:j+1)=="AC") then
counts=counts+1
endif


enddo
write(6,*)counts
counts=0
enddo



deallocate(s)
end