#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
void init();
int check(int i);
int check2(int j);
int getIndex(vector<int> v, int K);

int N, temp;
vector<int> X, Y, Z;

int getIndex(vector<int> v, int K)
{
	auto it = find(v.begin(), v.end(), K);
	if (it != v.end())
	{
		int index = it - v.begin();
		return index;
	}
	else {

		return -1;
	}
}

void init()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	X.push_back(0); Y.push_back(0); Z.push_back(0);
	cin >> N;
	for (int i = 0; i < N; i++) {
		scanf("%d", &temp);
		X.push_back(temp);
	}
	for (int i = 0; i < N; i++) {
		scanf("%d", &temp);
		Y.push_back(temp);
	}
	for (int i = 0; i < N; i++) {
		scanf("%d", &temp);
		Z.push_back(temp);
	}
	sort(X.begin(), X.end());
	sort(Z.begin(), Z.end());
}

int check(int i)
{

	int x = X[i], sum = 0;
	for (int j = 1; j <= N; j++) {
		if (Y[j] == x) {
			sum += check2(j);
		}
	}
	return sum;
}

int check2(int j)
{

	int ix = getIndex(Z, j), sum = 0, ct = 1;
	if (ix == -1) return 0;
	for (int i = ix + 1; i <= N; i++) {
		if (Z[i] == Z[ix]) ct++;
	}
	return ct;
}

int main()
{
	int sum = 0, ctr = 1;
	init();
	for (int i = 1; i <= N; i++) {
		if (X[i] == X[i - 1]) {
			ctr++;
			if (i == N) {
				sum += ctr * check(i);
			}
		}
		else {
			sum += ctr * check(i - 1);
			ctr = 1;
		}
	}
	printf("%d", sum);
}