N, Q = gets.split.map(&:to_i)
S = gets.chomp!
output = Array.new

Q.times do
    l, r = gets.split.map(&:to_i)
    temp = S.slice(l - 1, r - l + 1)
    output.push(temp.scan('AC').size) 
end

puts output
