import java.util.Scanner;
class Qujian{
float x1,x2,y1,y2;
Qujian(float x1,float x2,float y1,float y2){
this.x1 = x1;
this.x2 = x2;
this.y1 = y1;
this.y2 = y2;
}
boolean include(Qujian q){
if(this.x1<=q.x1&&this.x2>=q.x2&&this.y1<=q.y1&&this.y2>=q.y2)return true;
else return false;
}
}
public class Zju1139 {
public static void main(String args[])throws Exception{
Scanner in = new Scanner(System.in);
while(in.hasNext()){
int a = in.nextInt();
int count = 0;
Qujian[] q = new Qujian[a];
for(int i=0;i<a;i++){
q[i].x1 = in.nextFloat();
q[i].x2 = in.nextFloat();
q[i].y1 = in.nextFloat();
q[i].y2 = in.nextFloat();
}
for(int i=0;i<a;i++){
for(int j=0;j<a;j++){
if(i!=j){
if(q[i].include(q[j]))count++;
}
}
}
System.out.println(count);
}
}
}