n,q = gets.split.map(&:to_i)
s = gets.chomp.to_s
ary = []
cnt = 0
q.times do
  as = gets.split.map(&:to_i)
  ss = s[as[0]-1..as[1]-1]
  while ss.include?("AC") do
    ss.sub!("AC",'')
    cnt += 1
  end
  ary << cnt
  cnt = 0
end
puts ary