n,q = gets.split(" ").map(&:to_i)
s = gets.chomp.split("")
aci = Array.new(s.length-1)
for i in 0..s.length-2 do
    if s[i] == "A" && s[i+1] == "C"
        aci[i] = 1
    elsif
        aci[i] = 0
    end
end

acii = Array.new
q.times do
    l,r = gets.split(" ").map(&:to_i)

    acii = aci[l-1,r-l]
    puts acii.inject(:+)
end