#Atcoder ABC 122 C
n,q=gets.split.map{|u| u.to_i}
s=gets.chomp
lr=[]
q.times{
    l,r=gets.split.map{|u| u.to_i}
    lr.push([l-1,r-1])
}
data=[0]*(n+1)
if s[0..1]=="AC"
    data[0]=1
end
for i in 1...n-1
    if s[i..i+1]=="AC"
        data[i]+=1
    end
    data[i]+=data[i-1]
end
lr.each do |l,r|
    puts data[r-1]-data[l-1]
end