program main
integer(8)::n,q,i
integer(8),allocatable::a(:),l(:),r(:)
character(len=100000)::s

read*,n,q
allocate(a(n),r(q),l(q))
read*,s
a=0

do i=1,q
read*,l(i),r(i)
enddo

do i=1,n
if(s(i:i+1)=="AC") a(i+1)=1
enddo

do i=1,q
print"(i0)",sum(a(l(i),r(i)))
enddo

end program main