#include <iostream>

using namespace std;
int x[100000];
int y[100000];
int z[100000];

int main()
{
    int n, mogucnosti, indeks;
    mogucnosti = 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 k = 1; k <= n; k++) {

        for (int i = 1; i <= n; i++) {
            if (x[k] == y[i]) {
                indeks = i;
                for (int j = 0; j <= n; j++) {
                    if (indeks == z[j])
                    {
                        mogucnosti++;

                    }
                }

            }
        }
    }
    cout << mogucnosti;

    return 0;
}