n,q = gets.chomp.split(' ').map(&:to_i)
s = gets.chomp
arr = Array.new(n,0)
count = 0
for i in 0..(n-2)
  if s[i] == "A" && s[i+1] == "C"
    count += 1
  end
  arr[i+1] = count
end
quiz = []
q.times do
  quiz.push(gets.chomp.split(' ').map(&:to_i))
end
quiz.each do |q|
  puts arr[q[1]-1] - arr[q[0]-1]
end
