CONST = 'AC'
CONST.freeze

str_len = 0
q_num = 0
check_str_readed = false
check_str = ''
STDIN.each do |line|
  if q_num.zero?
    str_len, q_num = line.chomp.split.map! {|v| v.to_i}
    check_str_readed = false
    next
  end
  unless check_str_readed
    check_str = line.chomp
    check_str_readed = true
    next
  end
  start_pos, end_pos = line.chomp.split.map! {|v| v.to_i}
  s = check_str[start_pos - 1, end_pos - start_pos + 1]
  p s.each_char.each_cons(2).map {|v| v.join}.count {|n| n == CONST}
  q_num -= 1
end