//Problem Practice D - Untidy Desktops

#include <iostream.h>

struct win
{
	int r,c,w,h;
};

//do windows A and B overlap? This is not efficient
int overlap(win A, win B)
{
	int i,j;

	for(i=A.r;i<A.r+A.h; i++)
		for(j=A.c;j<A.c+A.w;j++)
			if(B.r<=i && i<B.r+B.h && B.c<=j && j<B.c+B.w)
				return 1;

	return 0;
}

void main()
{
	int n, Overlap[51],i,j,count;
	win W[51];

	cin>>n;
	while(n>0){
		for(i=1;i<=n;i++)
			cin>>W[i].r>>W[i].c>>W[i].w>>W[i].h;

		for(i=1;i<=n;i++)
			Overlap[i]=0;		//Overlap[i]=1 if window i overlaps
								//with another window
		for(i=1;i<=n;i++)
			for(j=i+1;j<=n;j++)
			  if(overlap(W[i],W[j])) {
					Overlap[i]=Overlap[j]=1;
			  }

		count=0;
		for(i=1;i<=n;i++)
			if(Overlap[i])
				count++;

			cout<<count<<endl;

		cin>>n;
	}
}
