n, q = gets.split.map(&:to_i)
s = gets.chomp
count = 0
q.times do
  start_point, end_point =  gets.split.map(&:to_i)
  str = s[start_point-1..end_point-1]
  (0..str.size-2).each do |i|
    if str[i..i+1] == 'AC'
      count += 1
    end
  end
  puts count
  count = 0
end
