n, q = gets.split.map(&:to_i)
s = gets.chomp
answers = []
q.times do
  l, r = gets.split.map(&:to_i)
  str = s[(l-1)..(r-1)]
  count = 0
  str.length.times do |loopc|
    if str[(loopc - 1)..loopc] == "AC"
      count += 1
    end
  end
  answers.push(count)
end
puts answers