<>;while(<>){%t=$s=0;@@=sort{$b-$a}map$t{$_},grep!$t{$_}++,glob<>;$s++,map($@[$_]--,0..2),@@=sort{$b-$a}@@while$@[2];print$s,$/}