n,q = gets.split.map(&:to_i)
s = gets.chomp
q.times do |i|
    ans = 0
    l,r = gets.split.map(&:to_i)
    x=s[l-1..r-1]
    x.split('').each_with_index do |t,j|
        next if j==x.length-1
        if t=='A' && x[j+1]=='C'
            ans+=1
        end
    end
    puts ans
end