n, q = gets.split.map(&:to_i)
s = gets.chomp
q.times do
  l, r = gets.split.map(&:to_i)
  ss = s.slice(l - 1, r - l + 1)
  before_len = ss.length
  ss.gsub!("AC", "")
  after_len = ss.length
  puts (before_len - after_len) / 2
end
