n,a,b=$<.map{_1.split.map &:to_i} p a.permutation.map{|c|c.zip(b).sum{[0,_1-_2].max}}.tally.max[1]