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