N, Q = gets.chomp.split(" ").map{|s| s.to_i }
S = gets.chomp

q_arr = []
Q.times do |i|
  q_arr << gets.chomp.split(" ").map{|s| s.to_i }
end

#(N-1).times do |i|
#  iarr << i+1 if S[i..(i+1)] == "AC"
#end

q_arr.each do |l, r|
  p S[(l-1)..(r-1)].count("AC")
  #count = 0
  #iarr.each do |ind|
  #  next if l > ind
  #  break if ind >= r
  #  count += 1
  #end

  #puts count
end
