#include "stdio.h"
int v[1002][1002],a[4],n,i,j,c;
int main()
{
	for (scanf("%d",&n);~scanf("%d %d %d %d",&n,&i,&j,&c);v[j][i]-=1){v[n][i] += 1;v[j][c] += 1;v[n][c] -= 1;}
	for (i = 0; j = i<1002; i++)for (; j<1002; v[i][j] += v[i][j++-1]);
	for (j = 0; i = j<1002; i++)for (; i<1002; v[i][j] += v[i++-1][j]);
	for (i = 0; i<1002; i++)
		for (j = 0; j < 1002; j++)
			c = c>v[i][j]?c:v[i][j];
	printf("%d\n", c);
	scanf("%d",&n);
	return 0;
}


