n, q = gets.split.map(&:to_i)
s = gets.chomp

acs = []
s.length.times do |loopc|
  if s[(loopc - 1)..loopc] == "AC"
    acs.push(loopc - 1)
  end
end

#p acs

answers = []
q.times do
  l, r = gets.split.map(&:to_i)
  count = l - 1
  res = 0
  (r - l).times do
    if acs.include?(count)
      res += 1
    end
    count += 1
  end
  answers.push(res)
  #answers.push(acs.select {|i| i.between?(l-1,r-2)}.length)
  #answers.push()
end
puts answers