A=gets.split.map(&:to_i).permutation B=gets.split.map(&:to_i) PROFIT = A.map{|as| [as ,B]}.map{|x| x[0].zip(x[1])}.map{|ab_ab| ab_ab.map{|ab| [ab.inject(:-), 0].max}}.map(&:sum) puts PROFIT.count(PROFIT.max)