n,q = gets.chomp.split(" ").map{|e|e.to_i}
s = gets.chomp.split("")

ac = Array.new(n-1, 0)

0.upto(n-2) do |i|
	if s[i]=="A" && s[i+1]=="C" then ac[i]=1 end
end

q.times do
	l,r = gets.chomp.split(" ").map{|e|e.to_i}
	c = 0
	(l-1).upto(r-2) do |i|
		c += ac[i]
	end
	p(c)
end