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