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

void kuvanje()
{
	int n;
	cin >> n;

	vector <int> jela;
	jela.push_back(0);
	for (size_t i = 0; i < n; i++)
	{
		int y;
		cin >> y;
		jela.push_back(y);
	}

	vector <int> rec;
	rec.push_back(0);
	for (size_t i = 0; i < n; i++)
	{
		int y;
		cin >> y;
		rec.push_back(y);
	}

	vector <int> scen;
	scen.push_back(0);
	for (size_t i = 0; i < n; i++)
	{
		int y;
		cin >> y;
		scen.push_back(y);
	}

	int rez = 0;
	
	for (size_t i = 1; i <= n; i++)
		for (size_t j = 1; j <= n; j++)
			if (jela[i] == rec[scen[j]])rez++;
		
	
		cout << rez;
}



int main()
{
    ios::sync_with_stdio(0);
	cin.tie(0);
	kuvanje();

    return 0;
}