N, Q = gets.split.map(&:to_i)
S = gets.chomp
Q.times do
  l, r = gets.split.map(&:to_i)
  t = S[(l-1)..(r-1)]
  ans = 0
  (t.size - 1).times do |i|
    ans += 1 if t[i..(i+1)] == 'AC'
  end
  puts ans
end