$n=<>; $a=<>; @b1=sort{$a<=>$b}<>=~/\d+/g; $c=<>; @d1=sort{$b<=>$a}<>=~/\d+/g; $\=0; for(1..$n){ @b=@b1 if!@b; @d=@d1 if!@d; if(@b<@d){ $b=pop@b; $\++if@r=grep{$b>$d[$_]}0..@d-1; splice(@d,$r[0],1); }else{ $d=pop@d; $\++if@r=grep{$b[$_]>$d}0..@b-1; splice(@b,$r[0],1); } } print