#coding: euc-jp
class Main
  def self.main
    n, q = read1
    s = read2
    d = Array.new(n, 0)
    pos = 0
    (n - 1).times do |pos|
      d[pos + 1] = d[pos] + (s[pos, 2] == 'AC' ? 1 : 0)
    end
    q.times do
      l, r = read1
      puts d[r - 1] - d[l - 1]
    end
  end

  def self.read1
    gets.chomp.split.map(&:to_i)
  end
  def self.read2
    gets.chomp
  end
end

Main.main
