import itertools N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) A = sorted(A, reverse=True) B = sorted(B) M = sum([max(0, a - b) for a, b in zip(A, B)]) res = 0 for lis in itertools.permutations(A): if sum([max(0, a - b) for a, b in zip(lis, B)]) == M: res += 1 print(res)