#include <iostream>

using namespace std;

int compare(const void *a,const void *b)
{
	const int *x= (int*)a;
	const int *y= (int*)b;
	if(*x>*y){return 1;}
	if(*x<*y){return -1;}
	return 0;
}

int main()
{
	int n;
	long long rez=0,prez=0;
	cin >> n;
	int x[n],y[n],z[n];
	for(int i=0;i<n;i++){cin >> x[i];}
	for(int i=0;i<n;i++){cin >> y[i];}
	for(int i=0;i<n;i++){cin >> z[i];}
	qsort(x,n,sizeof(int),compare);
	qsort(z,n,sizeof(int),compare);
	for(int j=0;j<n;j++)
	{
		//cout << "x[" << 0 << "] = " << x[0] << " , " << "y[" << j << "] = " << y[j] << endl;
		if(x[0]==y[j])
		{
			j++;
			for(int h=0;h<n;h++)
			{
				//cout << "j = " << j << " , " << "z[" << h << "] = " << z[h] << endl;
				if(j==z[h])
				{
					while(j==z[h]){prez++;h++;}
					//cout << "prez = " << prez << endl;
					h=n;
				}
			}
			j--;
		}
	}
	rez+=prez;		
	for(int i=1;i<n;i++)
	{
		if(x[i]==x[i-1]){rez+=prez;}
		else{
			prez=0;
			for(int j=0;j<n;j++)
			{
				//cout << "x[" << i << "] = " << x[i] << " , " << "y[" << j << "] = " << y[j] << endl;
				if(x[i]==y[j])
				{
					j++;
					for(int h=0;h<n;h++)
					{
						//cout << "j = " << j << " , " << "z[" << h << "] = " << z[h] << endl;
						if(j==z[h])
						{
							while(j==z[h]){prez++;h++;}
							h=n;
						}
					}
					j--;
				}
			}
			rez+=prez;
		}
	}
	cout << rez << endl;
	return 0;
}