local n,q=io.read("*n","*n","*l")
local s=io.read()
local t={0}
for i=1,n-1 do
    t[i+1]=t[i]+(s:sub(i,i+1)=="AC" and 1 or 0)
end
for i=1,q do
    local l,r=io.read("*n","*n")
    print(t[r]-t[l])
end