N, Q=gets.split.map(&:to_i)
S=gets.chomp
lrs=Q.times.map { gets.split.map(&:to_i) }

sum=0
sum_array=[0]

(N-1).times do |i|
  sum += 1 if S[i]=="A" && S[i+1] == "C" 
  sum_array.push(sum)
end

lrs.each do |lr|
  p sum_array[lr[1]-1] - sum_array[lr[0]-1]
end
