import itertools n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) max_ = 0 for ptn in itertools.permutations(a): tmp = 0 for aa, bb in zip(ptn, b): tmp += max(aa - bb, 0) max_ = max(max_, tmp) ans = 0 for ptn in itertools.permutations(a): tmp = 0 for aa, bb in zip(ptn, b): tmp += max(aa - bb, 0) if tmp == max_: ans += 1 print(ans)