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