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