from collections import defaultdict import itertools as it n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) cnt = defaultdict(int) for ap in it.permutations(a, n): s = sum(max(0, ap[i] - b[i]) for i in range(n)) cnt[s] += 1 x = max(list(cnt.keys())) print(cnt[x])