#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int n, br = 0;
	cin >> n;
	
	cin.tie(0);
	int x[n], y[n], z[n], a[3][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];
	
	sort(z+1, z+n+1);
		
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <=n; j++){
			if (x[i] == y[z[j]])
				br++;
		}		
	} 
	
	cout << br;
	
	return 0;
}