N, Q = gets.split.map(&:to_i)
S = gets.chomp
LRs = readlines.map{|l| l.split.map(&:to_i)}

a = Array.new(N + 1, 0)
c = ''
n = 0
(2 .. N).each do |i|
  n += 1 if S[i - 2] == 'A' && S[i - 1] == 'C'
  a[i] = n
end
LRs.each do |l, r|
  puts a[r] - a[l]
end