#include <cstdio>
#include <ctime>
#include <cassert>
#include <algorithm>
#include <set>
#include <cmath>
using namespace std;
#define y1 stupid_cmath
#define maxn 400010
int xc,active,ans,in_set[maxn];
struct line{
int x1,y1,x2,y2,idx;
double getyc(){
return (double)y1+double(y2-y1)/(double)(x2-x1)*(double)(xc-x1);
}
bool operator<(const line&he)const{
double yc1=(long double)he.y1+(long double)(he.y2-he.y1)/(long double)(he.x2-he.x1)*(long double)(xc-he.x1);
double yc2=(long double)y1+(long double)(y2-y1)/(long double)(x2-x1)*(long double)(xc-x1);
return yc2<yc1;
}
bool operator==(const line&he)const{
return (idx==he.idx);
}
line(){}
line(int x1,int y1,int x2,int y2,int idx):x1(x1),y1(y1),x2(x2),y2(y2),idx(idx){}
};
struct event{
line me;
int time,type;
bool operator<(const event&he)const{
return (time<he.time||(time==he.time&&type<he.type));
}
event(){}
event(line me,int time,int type):me(me),time(time),type(type){}
};
struct treap{
line key;
int prior,cnt;
treap*l,*r;
treap(){}
treap(line me,int prior):key(me),prior(prior),l(NULL),r(NULL),cnt(0){}
};
typedef treap * ptreap;
ptreap root;
int cnt(ptreap t){
if(!t)return 0;else return t->cnt;
}
void upd(ptreap&t){
if(t)t->cnt=1+cnt(t->l)+cnt(t->r);
}
void split(ptreap t,line key,ptreap&l,ptreap&r){
if(!t){l=r=NULL;return;}
if(key<t->key)split(t->l,key,l,t->l),r=t;else split(t->r,key,t->r,r),l=t;
upd(t);
upd(l);
upd(r);
}
void insert(ptreap&t,ptreap it){
if(!t)t=it;else
if(it->prior>t->prior)split(t,it->key,it->l,it->r),t=it;else{
if(it->key<t->key)insert(t->l,it);else insert(t->r,it);
}
upd(t);
}
void merge(ptreap&t,ptreap l,ptreap r){
if(!l||!r)t=l?l:r;else
if(l->prior>r->prior)merge(l->r,l->r,r),t=l;else
merge(r->l,l,r->l),t=r;
upd(t);
}
void erase(ptreap&t,line key){
if(t->key==key)merge(t,t->l,t->r);else
if(t->key<key)erase(t->r,key);else erase(t->l,key);
upd(t);
}
int place(ptreap root,line me){
if(root->key==me)return cnt(root->l);
if(root->key<me)return cnt(root->l)+1+place(root->r,me);
return place(root->l,me);
}
int getkth(ptreap root,int k){
if(k==cnt(root->l))return root->key.idx;
if(k<cnt(root->l))return getkth(root->l,k);else return getkth(root->r,k-cnt(root->l)-1);
}
int n,i,x1,y1,x2,y2,en,rg,q,findnext,j,old;
event e[maxn];
line orig[maxn];
void wt(ptreap t){
if(!t)return;
wt(t->l);
printf("%.2lf ",t->key.getyc());
wt(t->r);
}
int main(){
// freopen("hillwalk.in","r",stdin);
// freopen("hillwalk.out","w",stdout);
srand(time(NULL));
scanf("%d",&n);
for(i=1;i<=n;i++){
scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
e[++en]=event(line(x1,y1,x2,y2,i),x1,i);
e[++en]=event(line(x1,y1,x2,y2,i),x2,-i);
orig[i]=line(x1,y1,x2,y2,i);
}
active=1,ans=1;
sort(e+1,e+en+1);
for(i=1;i<=en;i++)if(i>rg){
xc=e[i].time;
// wt(root);
findnext=0;
j=i;
while(j<en&&e[j+1].time==e[i].time)++j;
for(q=i;q<=j;q++)if(e[q].type>0){
insert(root,new treap(e[q].me,(rand()<<15)+rand()));
}else
if(e[q].type==-active)findnext=1;else erase(root,e[q].me);
if(findnext){
old=active;
in_set[active]=0;
int it=place(root,orig[active]);
if(it==0)break;
++ans;
active=getkth(root,--it);
erase(root,orig[old]);
}
rg=j;
}
printf("%d\n",ans);
return 0;
}
I2luY2x1ZGUgPGNzdGRpbz4KI2luY2x1ZGUgPGN0aW1lPgojaW5jbHVkZSA8Y2Fzc2VydD4KI2luY2x1ZGUgPGFsZ29yaXRobT4KI2luY2x1ZGUgPHNldD4KI2luY2x1ZGUgPGNtYXRoPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKI2RlZmluZSB5MSBzdHVwaWRfY21hdGgKI2RlZmluZSBtYXhuIDQwMDAxMAoKaW50IHhjLGFjdGl2ZSxhbnMsaW5fc2V0W21heG5dOwo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