from itertools import permutations N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) L = [] for b in permutations(B): TOTAL = 0 for i, j in zip(A, b): TOTAL += max(i-j, 0) L += [TOTAL] MAX = max(L) ANS = 0 for b in permutations(B): TOTAL = 0 for i, j in zip(A, b): TOTAL += max(i-j, 0) if TOTAL == MAX: ANS += 1 print(ANS)