<>,@$_=sort{$a-$b}glob<>for 0,1;map{$z[++$$_]=0while($m)=grep$_>$m,@{$|--};$|=1}a,b;print$#z