#include using namespace std; using ll=int64_t; //#define int ll #define FOR(i,a,b) for(int i=int(a);i CerrDummy& operator<<(CerrDummy&cd,const T&){ return cd; } using charTDummy=char; using traitsDummy=char_traits; CerrDummy& operator<<(CerrDummy&cd,basic_ostream&(basic_ostream&)){ return cd; } #define cerr cerrDummy #endif #define REACH cerr<<"reached"<; using vi=vector; using ld=long double; template ostream& operator<<(ostream& os,const pair& p){ os<<"("< ostream& operator <<(ostream& os,const vector& v){ os<<"{"; REP(i,(int)v.size()){ if(i)os<<","; os< void chmax(T& a,U b){ if(a void chmin(T& a,U b){ if(b T Sq(const T& t){ return t*t; } #define CAPITAL void Yes(bool ex=true){ #ifdef CAPITAL cout<<"YES"<rev^=true; if(r) r->rev^=true; rev=false; } val+=lz; if(l){ l->lz+=lz; } if(r){ r->lz+=lz; } lz=0; } int Get(){ return val+lz; } } ns[100010]; using NP=Node::NP; NP NewNode(int val){ static int used=0; NP ptr=ns+(used++); ptr->l=NULL; ptr->r=NULL; ptr->rev=false; ptr->val=val; ptr->lz=0; return ptr; } NP Merge(NP x,NP y){ if(!x)return y; if(!y)return x; if(x->key>y->key){ x->Propagate(); x->r=Merge(x->r,y); return x; }else{ y->Propagate(); y->l=Merge(x,y->l); return y; } } pair Split(NP x,int v){ if(!x)return MP(NP(NULL),NP(NULL)); x->Propagate(); if(x->Get()r,v); x->r=r.first; return MP(x,r.second); }else{ auto l=Split(x->l,v); x->l=l.second; return MP(l.first,x); } } NP MLN(NP x){ while(1){ x->Propagate(); if(x->l) x=x->l; else break; } return x; } NP MRN(NP x){ while(1){ x->Propagate(); if(x->r) x=x->r; else break; } return x; } pair SplitMLN(NP x){ assert(x); x->Propagate(); if(x->l){ auto l=SplitMLN(x->l); x->l=l.second; return MP(l.first,x); }else{ auto r=x->r; x->r=NULL; return MP(x,r); } } int ans; void Calc(NP x){ if(!x)return; x->Propagate(); if(x->vall); Calc(x->r); } signed main(){ int n=read(); NP root=NULL; REP(i,n+1) root=Merge(root,NewNode(inf)); cerr<lz==0); x->val=l; NP y=s2.second; if(y)y->lz++; root=Merge(Merge(s2.first,x),Merge(y,s3.second)); } Calc(root); print(ans); }