num, qnum, = gets.split.map(&:to_i)
str = gets.strip
ary = Array.new(num + 1, 0)
num.times do |t|
  ary[t + 1] = ary[t] + (str[t,2] == 'AC' ? 1 : 0)
end
qnum.times do
  ql, qr, = gets.split.map(&:to_i)
  puts ary[qr-1] - ary[ql-1]
end
