n,q=gets.split.map(&:to_i)
s = gets.chomp
sum=Array.new(n+1,0)
n.times do |i|
  sum[i+1] += sum[i]
  sum[i+1] += 1 if s[i,2] == 'AC'
end
q.times do
  l,r = gets.split.map(&:to_i)
  puts sum[r-1]-sum[l-1]
end
