local N, Q, _ = io.read("n", "n", "l")
local S_tmp = io.read("l")
local S = {}
for i=1,N do
    S[i] = string.sub(S_tmp, i, i)
end

local tbl = {}
tbl[0] = 0
local prev = '_'
for i=1,N do
    local c = S[i]
    if prev .. c == 'AC' then
        tbl[i] = tbl[i-1] + 1
    else
        tbl[i] = tbl[i-1]
    end
    prev = c
end

for i=1,Q do
    local l, r = io.read("n", "n")
    local count = tbl[r] - tbl[l]
    print(count)
end