#include <iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;
    int jela[n];
    int recept[n];
    int scenario[n];
    
    for (int i = 1; i <= n; i++){
        cin >> jela[i];
    }
    for (int i = 1; i <= n; i++){
        cin >> recept[i];
    }
    for (int i = 1; i <= n; i++){
        cin >> scenario[i];
    }
    
    long long int counter = 0;
    
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= n; j++){
            if (jela[i] == recept[scenario[j]]){
                counter++;
            }
        }
    }
    
    cout << counter;
}