n = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) M = 0 import itertools for p in itertools.permutations(A, n): temp = 0 for a, b in zip(p, B): temp += max(0, a-b) M = max(temp, M) ans = 0 for p in itertools.permutations(A, n): temp = 0 for a, b in zip(p, B): temp += max(0, a-b) if temp == M: ans += 1 print(ans)