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=[]
q[0]=0
p=0
for k in 0..n-2
  if s[k]=="A" && s[k+1]=="C"
    p+=1
    q[k+1]=p
  else
    q[k+1]=p
  end
end
for t in 0..m-1
  puts q[r[t]-1]-q[l[t]-1]
end