from itertools import permutations N = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) a.sort() b.sort(reverse=True) t = set(a[i] for i in range(N) if a[i] >= b[i]) result = 0 for x in permutations(a): if t == set(list(x)[:len(t)]): result += 1 print(result)