import itertools N = int(input()) A = list(map(int,input().split())) B = list(map(int,input().split())) A.sort(reverse=True) B.sort() MAX = 0 for i in range(N): temp = max(A[i] - B[i],0) MAX += temp ans = 0 L = list(itertools.permutations(A,N)) for X in L: point = 0 for i in range(N): temp = max(X[i] - B[i],0) point += temp if point == MAX: ans += 1 print(ans)