n, q = gets.split(' ').map(&:to_i)
s = gets.rstrip
lrs = []
q.times{lrs << gets.split(' ').map(&:to_i)}

ms = Array.new(n+1, 0)
0.upto(n-1) do | i |
  add = s[i, 2] == 'AC' ? 1 : 0
  ms[i+1] = ms[i] + add
end
lrs.each do | lr |
  p ms[lr[1]-1] - ms[lr[0]-1]
end