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

void kuvanje()
{
	int n;
	scanf("%d",&n);

	vector <int> jela(n+1,0);
	for (int i = 1; i <= n; i++)
		scanf("%d", &jela[i]);
	

	vector <int> rec(n + 1, 0);
	for (int i = 1; i <= n; i++)
		scanf("%d", &rec[i]);

	vector <int> scen(n + 1, 0);
	for (int i = 1; i <= n; i++)
		scanf("%d", &scen[i]);

	int rez = 0;
	
	for (int i = 1; i <= n; i++)
			for (int j = 1; j <= n; j++)
				if (jela[i] == rec[scen[j]])rez++;
		
	
	
	
	printf("%d", rez);
}



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

    return 0;
}