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

iarr = [0] # index調整兼index=1の時の初期値
count = 0
N.times do |i|
  count += 1 if S[i..(i+1)] == "AC"
  iarr << count
end

q_arr.each do |l, r|
  left = iarr[l-1] # lの時の増分を入れるために-1
  right = iarr[r-1] # rの時の増分を外すために-1

  puts right - left
end
