(*,n) = gets.split.map(&:to_i)
s = gets.chomp
ss = s.size
si = Array.new(ss, 0)
b = n.times.map{gets.split.map(&:to_i)}
index = []
i = s.index('AC')
while i != nil
 index << i
 (i+1...ss).each{|e|si[e]+=1}
 i = s.index('AC', i+1)
end
puts b.map { |e| si[e[1]-1] - si[e[0]-1]  }
