#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

int main()
{
    map<int, int>a;
    vector<int>b;
    int n, y, x, z;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> x;
        a[x]++;
    }
    for (int i = 0; i < n; i++) {
        cin >> y;
        b.push_back(y);
    }
    int br = 0;
    for (int i = 0; i < n; i++) {
        cin >> z;
        int ind = b[z - 1];
        br += a[ind];

    }
    cout << br;

}