#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
const int MOD=1000000007;

int x[2000],y[2000];
int main(){
	int n;cin>>n;
	rep(i,n){
		scanf("%d%d",&x[i],&y[i]);
	}
	int cnt=0;
	rep(i,n)for(int j=i+1;j<n;j++){
		int A=abs(x[j]-x[i]),B=abs(y[j]-y[i]);
		if(B<=A){
			cnt++;
		}
	}
	cout<<cnt<<endl;
}
#include<bits/stdc++.h>
typedef long long ll;
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define nep(i,r,l) for(int i=r;i>=l;i--)
void re(int &x){scanf("%d",&x);}
void re(int &x,int &y){scanf("%d %d",&x,&y);}
void re(ll &x){scanf("%lld",&x);}
void re(ll &x,ll &y){scanf("%lld %lld",&x,&y);}
void re(double &x){scanf("%lf",&x);}
void re(double &x,int &y){scanf("%lf %lf",&x,&y);}
using namespace std;
const int N=1e5+5;

int boom[N];
int a[N];
int main()
{
    ll n;re(n);
	ll t;
	ll ans=0;
	rep(i,1,n)
	{
		cin>>t;
		boom[t]++;
	}
	rep(i,1,n)
	{
		cin>>a[i];
	}
	rep(i,1,n)
	{
		cin>>t;
		ans+=boom[a[t]];
	}
	cout<<ans;
    return 0;
}
