The country of KhoaNali is structured as a giant road with $N$ buildings on both sides, the northern buildings being houses and the southern buildings being workplaces. Each house has a unique label $h_i$ and each workplace has a unique label $w_i$.

Person $x$ ($1 \leq x \leq N$) lives in house $i$ and goes to work at workplace $j$ if $h_i = w_j = x$.

Due to the recent NorocaVirus situation, everyone decided to distance himself from others. But due to the structure of KhoaNali, some of them may end up meeting someone else on their way. Your job is to find out the number of unordered pairs $(i, j)$ such that Person $i$ can meet Person $j$ on his way.

Input

The first line contains an integer $N$ ($1 \leq N \leq 10^5$) — the number of buildings on each side of the road.

Second line contains $N$ integers $h_1, h_2, \dots , h_N$ ($1 \leq h_i \leq N$) — labels of the houses.

Third line contains $N$ integers $w_1, w_2, \dots , w_N$ ($1 \leq w_i \leq N$) — labels of the workplaces.

Output

Print a single integer — the number of unordered pairs $(i, j)$ such that Person $i$ and Person $j$ can meet on their way.

Sample

Input

Output

4
1 2 3 4
2 4 1 3

3

In the sample the pairs that can meet are $(1, 2)$, $(1, 4)$, and $(3, 4)$.