N, Q = gets.split.map(&:to_i)
S = gets.chomp
LR = Q.times.map { gets.split.map(&:to_i) }

L = 0
R = 1

LR.each do |lr|
  puts S[(lr[L]-1)..(lr[R]-1)].scan('AC').size
end

__END__
8 3
ACACTACG
3 7
2 3
1 8
