#include "stdio.h"
#include<algorithm>
using namespace std;
int v[1002][1002],a[4],n,i,j,c;

int main()
{
	for (scanf_s("%d",&n);~scanf_s("%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 = max(c, v[i][j]);
		}
	}
	printf("%d\n", c);
	scanf_s("%d",&n);
	return 0;
}


