#include <bits/stdc++.h>

#define maxn 10000

#define unos(a, n)for(int i = 1;i<=n;i++)cin>>a[i];

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int resenje = 0, temp, n, xi[maxn], yi[maxn];
    vector<int> zi(maxn, 0);
    cin >> n;
    unos(xi, n);
    unos(yi, n);
    unos(zi, n);
    for(int i = 1; i <= n; i++){
        for(int j : zi){
            if(xi[i] == yi[j]){
                resenje++;
            }
        }
    }
    cout << resenje;
}