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

counter = Array.new(N + 2, 0)

0.upto(N - 2) do |i|
  if S[i..(i + 1)] == 'AC'
    counter[i + 1] = counter[i] + 1
  else
    counter[i + 1] = counter[i]
  end
end

query.each do |l, r|
  puts counter[r - 1] - counter[l - 1]
end
