#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<list>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define sgn(v) (abs((v))<eps?0:((v)<0?-1:1))
#define sqr(v) ((v)*(v))
#define MP make_pair
#define PB push_back
#define FI first
#define SE second
#define debug 0
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<double,int> PDI;
typedef pair<double,double> PDD;
typedef pair<int,int> PII;
typedef pair<int,LL> PIL;
typedef pair<LL,int> PLI;
typedef pair<LL,LL> PLL;
const double eps=1e-9;
const double pi=acos(-1);
vector<PDD> it,tp;
double ag[4];
bool cmpSE(PDD p,PDD q)
{
	if(sgn(p.SE-q.SE))return p.SE<q.SE;
	else return p.FI<q.FI;
}
bool cmpFI(PDD p,PDD q)
{
	if(sgn(p.FI-q.FI))return p.FI<q.FI;
	else return p.SE<q.SE;
}
bool In(double v,double l,double r)
{
	for(int k=-3;k<=3;++k)
		if((sgn(l-v-k*2*pi)<=0&&sgn(v+k*2*pi-r)<=0))return true;
	return false;
}
int main()
{
	//cout <<pi/4*3<<endl;
	int n,i,j,con;
	int x1,y1,x2,y2;
	double l,r,nr;
	scanf("%d",&n);
	for(i=0;i<n;++i)
	{
		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		ag[0]=atan2(y1,x1);ag[1]=atan2(y1,x2);
		ag[2]=atan2(y2,x1);ag[3]=atan2(y2,x2);
		sort(ag,ag+4);
		l=ag[0],r=ag[3];
		//cout <<ag[0]<<" "<<ag[1]<<" "<<ag[2]<<" "<<ag[3]<<endl;cout <<l<<" "<<r<<endl;
		if(sgn(r-l-pi)>0)
		{
			for(j=0;j<4;++j)if(sgn(ag[j])<0)ag[j]+=2*pi;
			sort(ag,ag+4);
			l=ag[0],r=ag[3];
		}
		//cout <<l<<" "<<r<<endl;
		if(sgn(l-r)>0)while(1);
		it.PB(MP(l,r));
	}
	sort(it.begin(),it.end());
	//for(i=0;i<it.size();++i)cout <<it[i].FI<<" "<<it[i].SE<<endl;
	int ans=n;
	for(i=0;i<it.size();++i)
	{
		nr=it[i].FI;
		tp.clear();
		con=1;
		for(j=0;j<i;++j)
		{
			if(In(nr,it[j].FI,it[j].SE))continue;
			tp.PB(MP(it[j].FI+2*pi,it[j].SE+2*pi));
		}
		for(j=i+1;j<it.size();++j)
		{
			if(In(nr,it[j].FI,it[j].SE))continue;
			tp.PB(it[j]);
		}
		sort(tp.begin(),tp.end(),cmpSE);
		//cout <<"This is l:"<<nr<<" "<<tp.size()<<endl;for(j=0;j<tp.size();++j)cout <<tp[j].FI<<" "<<tp[j].SE<<endl;
		for(j=0;j<tp.size();++j)
		{
			if(j==0||!(In(nr,tp[j].FI,tp[j].SE)))
				nr=tp[j].SE,++con;
		}
		ans=min(ans,con);
		nr=it[i].FI;
		tp.clear();
		con=1;
		for(j=0;j<i;++j)
		{
			if(In(nr,it[j].FI,it[j].SE))continue;
			tp.PB(MP(it[j].FI+2*pi,it[j].SE+2*pi));
		}
		for(j=i+1;j<it.size();++j)
		{
			if(In(nr,it[j].FI,it[j].SE))continue;
			tp.PB(it[j]);
		}
		sort(tp.begin(),tp.end(),cmpFI);
		//cout <<"This is l:"<<nr<<" "<<tp.size()<<endl;for(j=0;j<tp.size();++j)cout <<tp[j].FI<<" "<<tp[j].SE<<endl;
		for(j=0;j<tp.size();++j)
		{
			if(j==0||!(In(nr,tp[j].FI,tp[j].SE)))
				nr=tp[j].FI,++con;
		}
		ans=min(ans,con);
		//-----------------------------------------------use L-----------------------------------------------------
		nr=it[i].SE;
		tp.clear();
		con=1;
		for(j=0;j<i;++j)
		{
			if(In(nr,it[j].FI,it[j].SE))continue;
			tp.PB(MP(it[j].FI+2*pi,it[j].SE+2*pi));
		}
		for(j=i+1;j<it.size();++j)
		{
			if(In(nr,it[j].FI,it[j].SE))continue;
			tp.PB(it[j]);
		}
		sort(tp.begin(),tp.end(),cmpSE);
		//cout <<"This is r:"<<nr<<" "<<tp.size()<<endl;for(j=0;j<tp.size();++j)cout <<tp[j].FI<<" "<<tp[j].SE<<endl;
		for(j=0;j<tp.size();++j)
		{
			if(j==0||!(In(nr,tp[j].FI,tp[j].SE)))
				nr=tp[j].SE,++con;
		}
		ans=min(ans,con);
		nr=it[i].SE;
		tp.clear();
		con=1;
		for(j=0;j<i;++j)
		{
			if(In(nr,it[j].FI,it[j].SE))continue;
			tp.PB(MP(it[j].FI+2*pi,it[j].SE+2*pi));
		}
		for(j=i+1;j<it.size();++j)
		{
			if(In(nr,it[j].FI,it[j].SE))continue;
			tp.PB(it[j]);
		}
		sort(tp.begin(),tp.end(),cmpFI);
		//cout <<"This is r:"<<nr<<" "<<tp.size()<<endl;for(j=0;j<tp.size();++j)cout <<tp[j].FI<<" "<<tp[j].SE<<endl;
		for(j=0;j<tp.size();++j)
		{
			if(j==0||!(In(nr,tp[j].FI,tp[j].SE)))
				nr=tp[j].FI,++con;
		}
		ans=min(ans,con);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3620