#include<bits/stdc++.h>
using namespace std;
int main(){
    long long sum = 0;
    vector<long long> M;
    long long x,z,y;
    long long n; cin >> n;
    vector<long long> X;
    vector<long long> Y;
    vector<long long> Z;
    for(long long i = 0; i < n; i++){
        cin >> x;X.push_back(x);
    }
    for(long long j = 0; j < n; j++){
        cin >> y;Y.push_back(y);
    }
    for(long long h = 0; h < n; h++){
        cin >> z;Z.push_back(z);
    }
    for(long long o = 0; o < X.size(); o++){
        for(long long k = 0; k < Y.size(); k++){
            if(X[o] == Y[k]){
                M.push_back(k+1);
            }
        }
    }
    for(long long v = 0; v < Z.size(); v++){
        for(long long q = 0; q < M.size(); q++){
            if(Z[v] == M[q]){
                sum++;
            }
        }
}
cout << sum;
}