#include <iostream>

using namespace std;

int main()
{
    int N, x[100000], y[100000], z[100000], k = 0;
    cin >> N;
    for(int i = 1; i <= N; i++)
        cin >> x[i];
    for(int i = 1; i <= N; i++)
        cin >> y[i];
    for(int i = 1; i <= N; i++)
    {
        cin >> z[i];
        for(int j = 1; j <= N; j++)
            if(x[j] == y[z[i]])
                k++;
    }
    cout << k;






    return 0;
}