n, qs = gets.split(' ').map(&:to_i)
s = gets.to_s
c = []
qs.times do |q|
  l, r = gets.split(' ').map(&:to_i)
  x = s[l - 1..r - 1]
  arr = x.scan('AC')
  c << arr.length
end
c.each { |ans| puts ans }
