import sys input = sys.stdin.readline from collections import * def compress(l): l = list(set(l)) l.sort() idx = defaultdict(int) for i in range(len(l)): idx[l[i]] = i return idx class BIT: def __init__(self, n): self.n = n self.bit = [0]*(n+1) def add(self, i, x): i += 1 while i<=self.n: self.bit[i] += x i += i&(-i) def acc(self, i): s = 0 while i>0: s += self.bit[i] i -= i&(-i) return s N = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) a.sort() idx = compress(a+b) ans = 0 bit = BIT(2*N) for ai, bi in zip(a, b): bit.add(idx[bi], 1) ans += bit.acc(idx[ai]) print(ans)