n,m=gets.chomp.split(" ").map{|s| s.to_i}
s=gets.chomp.split("")
l,r=[],[]
for t in 0..m-1
  l[t],r[t]=gets.chomp.split(" ").map{|k| k.to_i}
end
q=[]
p=0
for k in 0..n-2
  if s[k]=="A" && s[k+1]=="C"
    q[p]=k+1
    p+=1
  end
end
for t in 0..m-1
  c=0
  q.each{|a|
    if a>=l[t] && a<r[t]
     c+=1
    end
  }
  puts c
end