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

cnt = 0
array = Array.new(seq.length, 0)

(seq.length-1).times do |i|
  cnt += 1 if seq[i..i+1].match(/AC/)
  array[i+1] = cnt
end

lr.each do |v|
  puts array[v[1]-1]-array[v[0]-1]
end