from collections import * from itertools import permutations N = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) cnt = defaultdict(int) for p in permutations(a): score = 0 for pi, bi in zip(p, b): score += max(0, pi-bi) cnt[score] += 1 M = max(cnt.keys()) print(cnt[M])