# Main Loop
tmp = STDIN.gets().split(" ")
q = tmp[1].to_i
s0 = STDIN.gets().chomp
q.times do
  tmp = STDIN.gets().split(" ")
  l = tmp[0].to_i - 1
  r = tmp[1].to_i - 1
  s = s0.slice(l..r)
  n = 0
  for i in 0..(r - 2)
    if s[i] == "A"
      if s[i + 1] == "C"
        n += 1
      end
      i += 1
    end
  end
  puts n
end
