N = int(input()) a = list(map(int,input().split())) b = list(map(int,input().split())) import itertools _max = 0 count = 0 for v in itertools.permutations(range(N)): Sum = 0 for k in range(N): if a[v[k]] > b[k]: Sum += a[v[k]] - b[k] if Sum == _max: count += 1 elif Sum > _max: _max = Sum count = 1 print(count)