N, Q = gets.split.map(&:to_i)
seq = gets.chomp
lr = Array.new(Q){gets.split.map(&:to_i)}

#0からn文字目まで切り出したときのACの数
cum = Array.new(seq.length,0)
cnt = 0
(seq.length-1).times do |i|
  p seq.slice(i,2)
  if seq.slice(i,2).include?("AC")
    cnt += 1
  end
  cum[i+1] = cnt
  p cum
end

Q.times do |i|
  puts cum[lr[i][1]-1] - cum[lr[i][0]-1]
end