n, q = gets.split(" ").map(&:to_i)
s = gets.chomp.to_s

ary = []
q.times do
  ary << gets.split(" ").map(&:to_i)
end

ary_num = Array.new(n, 0)
cnt = 0

(n-1).times do |i|
  if s[i..i+1] == "AC"
    cnt += 1
  end
  ary_num[i+1] = cnt
end

ary.each do |x|
  puts ary_num[x[1]-1] - ary_num[x[0]-1]
end