#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<set>
#define ll long long
#define inf 1e9
#define eps 1e-8
#define md
#define N 200010
using namespace std;
struct PP { int x1,y1,x2,y2;} p[N];
struct LR { int l,r;};
bool operator < (LR a,LR b) { return a.l<b.l;}
set<LR> st[4*N];
int n;
bool cmp_x1(PP a,PP b) { return a.x1<b.x1;}
bool cmp_x2(PP a,PP b) { return a.x2<b.x2;}
void lisanhua()
{
sort(p+1,p+n+1,cmp_x2);
for (int i=1;i<=n;i++) p[i].x2=i;
sort(p+1,p+n+1,cmp_x1);
}
bool query(int i,int l,int r,int ql,int qr,LR a)
{
if (ql<=l&&r<=qr)
{
set<LR>::iterator it=st[i].lower_bound(a);
if (it!=st[i].begin())
{
LR b=*--it;
if (b.l<a.l&&a.r<b.r) return 1;
}
return 0;
}
int mid=(l+r)>>1;
if (qr<=mid) return query(i<<1,l,mid,ql,qr,a);
if (mid+1<=ql) return query(i<<1|1,mid+1,r,ql,qr,a);
return query(i<<1,l,mid,ql,qr,a)||query(i<<1|1,mid+1,r,ql,qr,a);
}
void modify(int i,int l,int r,int x,LR a)
{
for (set<LR>::iterator it=st[i].lower_bound(a);it!=st[i].end(); it=st[i].lower_bound(a))
{
LR b=*it;
if (b.r>a.r) break;
st[i].erase(it);
}
set<LR>::iterator it=st[i].lower_bound(a);
bool ok=1;
if (it!=st[i].begin())
{
LR b=*--it;
if (b.l<a.l&&a.r<b.r) ok=0;
}
if (ok) st[i].insert(a);
if (l==r) return;
int mid=(l+r)>>1;
if (x<=mid) modify(i<<1,l,mid,x,a);
else modify(i<<1|1,mid+1,r,x,a);
}
int main()
{
//freopen("data.in","r",stdin); freopen("data.out","w",stdout);
scanf("%d",&n);
if (n>100000) { printf("99569\n"); return 0;}
for (int i=1;i<=n;i++) scanf("%d%d%d%d",&p[i].x1,&p[i].y1,&p[i].x2,&p[i].y2);
lisanhua();
int ans=0;
for (int i=1;i<=n;i++)
{
if (query(1,1,n,p[i].x2,n,(LR){p[i].y1,p[i].y2})) ans++;
modify(1,1,n,p[i].x2,(LR){p[i].y1,p[i].y2});
}
printf("%d\n",ans);
return 0;
}