# N <= 9なので順列全探索が可能 (O(N!N) # 逆に得点最大の選び方の数をとわれているので全探索するべき? from itertools import permutations from collections import Counter N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) score_max = 0 cnt = Counter() for p in permutations(A): tmp = 0 for i in range(N): tmp += max(0,p[i]-B[i]) score_max = max(score_max, tmp) cnt[tmp] += 1 print(cnt[score_max])