import itertools n=int(input()) a=[*map(int,input().split())] b=[*map(int,input().split())] A=[*itertools.permutations(a)] chk=[] for i in A: cnt=0 for j in range(n): if i[j]>b[j]: cnt+=i[j]-b[j] chk.append(cnt) print(sum(max(chk)==i for i in chk))