n, q = gets.chomp.split.map(&:to_i)
s = gets
l, r = [], []
cnt = 0
q.times do |hoge|
    l[hoge], r[hoge] = gets.chomp.split.map(&:to_i)
end

q.times do |hoge|
    bubun = s[(l[hoge] - 1)..(r[hoge] - 1)]
    bubun.size.times do |huga|
        if bubun[huga..huga + 1] == "AC" then
            cnt += 1
        end
    end
    puts cnt
    cnt = 0
end