#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=110;
int top[maxn];
int mid[3][maxn];
int bot[maxn];
int N;
int ans=0;

int main()
{
	scanf("%d",&N);
	for(int i=1;i<=N;i++)
	  scanf("%d",top+i);
	for(int i=1;i<=N;i++){
		scanf("%d",&mid[1][i]);
		for(int j=1;j<=N;j++)
		{
		  if(top[j]<mid[1][i])
		    mid[2][i]++;
		}
	}
	for(int i=1;i<=N;i++){
		scanf("%d",bot+i);
		for(int j=1;j<=N;j++){
		  if(mid[1][j]<bot[i]){
		    ans+=mid[2][j];
		  }
		}
	}
	printf("%d\n",ans);
	return 0;
}