from bisect import bisect_left N = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) a.sort() t0 = [] t1 = [] result = 0 for i in range(N): t1.append(b[i]) result += bisect_left(t0, a[i]) result += sum(1 for b in t1 if b < a[i]) if len(t1) == 500: t0.extend(t1) t0.sort() t1.clear() print(result)