n, a, b = 3.times.map { gets } n = n.to_i a = a.split(' ').map(&:to_i) b = b.split(' ').map(&:to_i) count = 0 current_max_score = 0 a.sort.permutation.each do |array| score = n.times.map do |i| diff = array[i] - b[i] diff >= 0 ? diff : 0 end.sum if score > current_max_score count = 1 current_max_score = score elsif score == current_max_score count += 1 end end puts count