n = gets.to_s.to_i a = gets.to_s.split.map(&:to_i) b = gets.to_s.split.map(&:to_i) i = 0 m = 0 ans = 0 a.permutation do |a| s = 0 a.each_with_index do |e, i| if e > b[i] s += e - b[i] end end if s > m ans = 1 m = s elsif s == m ans += 1 end end puts ans