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

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

	vector <int> jela(n+1,0);
	for (size_t i = 1; i <= n; i++)
		cin >> jela[i];
	

	vector <int> rec(n + 1, 0);
	for (size_t i = 1; i <= n; i++)
		cin >> rec[i];

	vector <int> scen(n + 1, 0);
	for (size_t i = 1; i <= n; i++)
		cin >> scen[i];

	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;
}