def ints
  gets.split.map(&:to_i)
end

N, Q = ints
S = gets.strip

Q.times do
  l, r = ints
  l -= 1
  r -= 1

  ans = 0
  l.upto(r - 1) do |i|
    # puts "#{i} #{S[i] + S[i + 1]}"
    if S[i] == 'A' && S[i + 1] == 'C'
      ans += 1
    end
  end
  puts ans
end
