#include <iostream>
using namespace std;

int main() {
    int n;
    cin >> n;

    int *x = new int[n];
    int *y = new int[n];
    int *z = new int[n];

    for (int i = 0; i < n; i++) {
        cin >> x[i];
    }

    for (int i = 0; i < n; i++) {
        cin >> y[i];
    }

    for (int i = 0; i < n; i++) {
        cin >> z[i];
    }

    int count = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (x[i] == y[z[j]-1]) {
                count++;
            }
        }
    }

    cout << count << endl;

    delete[] x;
    delete[] y;
    delete[] z;

    return 0;
}