You want to count the instances in a selection...
counts=[]
ss.each{|e|counts<< e.definition if e.class==Sketchup;;ComponentInstance}
countsuniq=counts.uniq
compocount=[]
countsuniq.each{|e|
count=0
counts.each{|c|count+=1 if c==e}
compocount<< [e.name, count]
}
### compocount is an array, with each item as an array of the instance's definition.name [you could change it to just the definition itself 'e' ?] and then its number of instances as counted in the selection (ss)...