n,q=gets.split.map(&:to_i)
s=gets.chomp
lrs=[]
q.times{lrs << gets.split.map(&:to_i)}
account=[]
n.times{|i| account.push(s[0..i].scan("AC").size)}
lrs.each do |lr|
  puts account[lr[1]-1]-account[lr[0]-1]
end
