#include <iostream>

using namespace std;

int main()
{
    unsigned long long int n;
    int zbir=0;
    cin>>n;
    unsigned long long int niz[3][n];
    for(unsigned long long int i=0;i<3;i++){
        for(int j=0;j<n;j++){
            cin>>niz[i][j];
        }
    }
    for(unsigned long long int  i=0;i<n;i++){
        for(unsigned long long int  j=0;j<n;j++){
            if(niz[0][i]==niz[1][niz[2][j]-1]){
                zbir++;
            }
        }

    }
    cout<<zbir;
    return 0;
}