N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) from collections import defaultdict scores = defaultdict(lambda: 0) max_score = 0 from itertools import groupby, accumulate, product, permutations, combinations for perm in permutations(A, N): score = 0 for i in range(N): score += max(0, perm[i]-B[i]) scores[score] += 1 max_score = max(max_score, score) print(scores[max_score])