n, q = gets.split.map(&:to_i)
s = gets.chomp

results = q.times.map do
  l, r = gets.split.map(&:to_i)
  ss = s[l-1..r-1]

  count = 0
  (0..ss.length - 2).each do |i|
    count += 1 if ss[i] == 'A' && ss[i + 1] == 'C'
  end
  count
end
puts results
