N, Q = gets.split(' ')
S = gets.chomp
count = []
Q.to_i.times do
    l, r = gets.split(' ')
    l = l.to_i
    r = r.to_i
    str = S[l-1,r-l+1]
    array = str.scan(/AC/)
    count << array.length
end

count.each do |x|
    puts x
end