gets.to_i.times{ gets a=[0,0]+gets.split.group_by{|i|i}.values.map(&:size).sort cnt=0 while a[-3]>0 (1..3).each{|i|a[-i]-=1} a.sort! cnt+=1 end p cnt }