#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

using ld = long double;
using Point =  complex<ld>;
const ld eps = 1e-12;
const ld pi = acos(-1.0);

bool eq(ld a, ld b) {
	return (abs(a - b) < eps);
}

bool cmp(Point x,Point y){
	if(eq(x.real(),y.real()))return x.imag()<y.imag();
	return x.real()<y.real();
}

bool eqq(Point x,Point y){
	return eq(x.real(),y.real())&&eq(x.imag(),y.imag());
}
//内積
ld dot(Point a, Point b) {
	return real(conj(a)*b);
}
//外積
ld cross(Point a, Point b) {
	return imag(conj(a)*b);
}


//線分
//直線にするなら十分通い２点を端点とすればよい
class Line {
public:
	Point a, b;
};
//円
class Circle {
public:
	Point p;
	ld r;
};
//3点の位置関係
int ccw(Point a, Point b, Point c) {
	b -= a; c -= a;
	if (cross(b, c) > eps)return 1;//a,b,cが反時計回り
	if (cross(b, c) < -eps)return -1;//a,b,cが時計回り
	if (dot(b, c) < 0)return 2;//c,a,bの順に一直線
	if (norm(b) < norm(c))return -2;//a,b,cの順に一直線
	return 0;//a,c,bの順に一直線
}
//2直線の交差判定
bool isis_ll(Line l, Line m) {
	return !eq(cross(l.b - l.a, m.b - m.a), 0);
}
//直線と線分の交差判定
bool isis_ls(Line l, Line s) {
	return (cross(l.b - l.a, s.a - l.a)*cross(l.b - l.a, s.b - l.a) < eps);
}
//点が直線上に存在するか
bool isis_lp(Line l, Point p) {
	return (abs(cross(l.b - p, l.a - p)) < eps);
}
//点が線分上に存在するか
bool isis_sp(Line s, Point p) {
	return (abs(s.a - p) + abs(s.b - p) - abs(s.b - s.a) < eps);
}
//線分と線分の交差判定
bool isis_ss(Line s, Line t) {
	if (isis_sp(s, t.a) || isis_sp(s, t.b) || isis_sp(t, s.a) || isis_sp(t, s.b))return true;
	return(cross(s.b - s.a, t.a - s.a)*cross(s.b - s.a, t.b - s.a) < -eps && cross(t.b - t.a, s.a - t.a)*cross(t.b - t.a, s.b - t.a) < -eps);
}
//点から直線への垂線の足
Point proj(Line l, Point p) {
	ld t = dot(p - l.a, l.a - l.b) / norm(l.a - l.b);
	return l.a + t * (l.a - l.b);
}
//直線と直線の交点
//平行な２直線に対しては使うな！！！！
Point is_ll(Line s, Line t) {
	Point sv = s.b - s.a; Point tv = t.b - t.a;
	return s.a + sv * cross(tv, t.a - s.a) / cross(tv, sv);
}
//直線と点の距離
ld dist_lp(Line l, Point p) {
	return abs(p - proj(l, p));
}
//直線と直線の距離
ld dist_ll(Line l, Line m) {
	return isis_ll(l, m) ? 0 : dist_lp(l, m.a);
}
//線分と直線の距離
ld dist_ls(Line l, Line s) {
	return isis_ls(l, s) ? 0 : min(dist_lp(l, s.a), dist_lp(l, s.b));
}
//線分と点の距離
ld dist_sp(Line s, Point p) {
	Point r = proj(s, p);
	return isis_sp(s, r) ? abs(p - r) : min(abs(p - s.a), abs(p - s.b));
}
//線分と線分の距離
ld dist_ss(Line s, Line t) {
	if (isis_ss(s, t))return 0;
	return min({ dist_sp(s,t.a),dist_sp(s,t.b),dist_sp(t,s.a),dist_sp(t,s.b) });
}

bool included(Point p,vector<Point>& pol){
    int n=pol.size();
    if(n<=2)return false;
    ld sum=0;
    rep(i,n-1){
        if(isis_sp(Line{pol[i],pol[i+1]},p))return false;
    }
    rep(i,n-1){
        sum+=arg((pol[i+1]-p)/(pol[i]-p));
    }
    return abs(sum)>eps;
}
//オーバーラップする線分があると壊れる
vector<vector<int>> segmentArrangement(const vector<Line>& segs, vector<Point>& ps) {
	int n = segs.size();
	rep (i, n) {
		ps.push_back(segs[i].a);
		ps.push_back(segs[i].b);
		rep (j, i) {
			if (isis_ss(segs[i],segs[j])){
	    		ps.push_back(is_ll(segs[i], segs[j]));
			}
    	}
	}
	sort(ps.begin(), ps.end(),cmp);
	ps.erase(unique(ps.begin(), ps.end(),eqq), ps.end());

	int m = ps.size();
	vector<vector<int>> gr(m);
	vector<pair<ld, int>> list;
	rep (i, n) {
		list.clear();	
		rep (j, m) {
			if (isis_sp(segs[i], ps[j]))list.push_back(make_pair(abs(segs[i].a-ps[j]), j));
		}
		sort(list.begin(), list.end());
		rep (j, list.size() - 1) {
			int a = list[j  ].second;
			int b = list[j+1].second;
			gr[a].emplace_back(b);
			gr[b].emplace_back(a);
		}
	}
	return gr;
}

struct LowLink {
    const vector<vector<int>> &g;
    vector< int > used, ord, low;
    vector< int > articulation;
    vector< pair< int, int > > bridge;
 
    LowLink(const vector<vector<int>> &g) : g(g) {}
 
    int dfs(int idx, int k, int par) {
        used[idx] = true;
        ord[idx] = k++;
        low[idx] = ord[idx];
        bool is_articulation = false;
        int cnt = 0;
        for(auto &to : g[idx]) {
            if(!used[to]) {
                ++cnt;
                k = dfs(to, k, idx);
                low[idx] = min(low[idx], low[to]);
                if(par!=-1&&low[to]>=ord[idx])is_articulation =true;
                if(ord[idx] < low[to]) bridge.emplace_back(minmax(idx, (int) to));
            }
            else if(to != par) {
                low[idx] = min(low[idx], ord[to]);
            }
        }
        if(par==-1&&cnt>1)is_articulation= true;
        if(is_articulation) articulation.push_back(idx);
        return k;
    }
 
    virtual void build() {
        used.assign(g.size(), 0);
        ord.assign(g.size(), 0);
        low.assign(g.size(), 0);
        int k = 0;
        for(int i = 0; i < g.size(); i++) {
            if(!used[i]) k = dfs(i, k, -1);
        }
    }
};

map<pair<int,int>,int> edges;
struct BiConnectedComponents : LowLink {
    using LL = LowLink;
 
    vector< int > used;
    vector< vector< pair< int, int > > > bc;
    vector< pair< int, int > > tmp;
 
    BiConnectedComponents(const vector<vector<int>> &g) : LL(g) {}
 
    void dfs(int idx, int par,int& k) {
        used[idx] = true;
        for(auto &to : this->g[idx]) {
            if(to == par) continue;
            if(!used[to] || this->ord[to] < this->ord[idx]) {
                tmp.emplace_back(minmax(idx, to));
            }
            if(!used[to]) {
                dfs(to, idx, k);
                if(this->low[to] >= this->ord[idx]) {
                    bc.emplace_back();
                    for(;;) {
                        auto e = tmp.back();
                        edges[e]=k;
                        edges[{e.second, e.first}]=k;
                        bc.back().emplace_back(e);
                        tmp.pop_back();
                        if(e.first == min(idx, to) && e.second == max(idx, to)) {
                        break;
                        }
                    }
                    k++;
                }
            }
        }
    }
 
    void build(int& k) {
        LL::build();
        used.assign(this->g.size(), 0);
        k = 0;
        for(int i = 0; i < used.size(); i++) {
            if(!used[i]) {
                dfs(i, -1, k);
            }
        }
    }
};



int main(){
    int n;
	cin>>n;
	vector<Line> segs(n);
	rep(i,n){
		double x,y,xx,yy;
		cin>>x>>y>>xx>>yy;
		segs[i] = Line{Point(x,y),Point(xx,yy)};
	}
	vector<Point> ps;
	auto G = segmentArrangement(segs,ps);
	n=G.size();
    BiConnectedComponents bc(G);
    int m=0;
    bc.build(m);
    vector<int> ans(m);
    for(auto g : bc.bc){
        if(g.size()>=3)ans[edges[g[0]]]++;
    }
    map<int,int> idx[n];
    vector<int> used[n];
    rep(i,n){
        sort(G[i].begin(),G[i].end(),[&](int x,int y){
            return arg(ps[x]-ps[i])>arg(ps[y]-ps[i]);
        });
        rep(j,G[i].size()){
            idx[i][G[i][j]]=j;
        }
        used[i].resize(G[i].size());
    }
    vector<vector<Point>> loops[m];
    
    rep(i,n){
        rep(j,G[i].size()){
            if(used[i][j])continue;
            used[i][j]=true;
            int pre=i,cur=G[i][j];
            vector<Point> loop;
            loop.push_back(ps[i]);
            loop.push_back(ps[cur]);
            while(cur!=i){
                int nxt=(idx[cur][pre]+1)%G[cur].size();
                while(used[cur][nxt]||edges[{pre,cur}]!=edges[{cur,G[cur][nxt]}])nxt=(nxt+1)%G[cur].size();
                used[cur][nxt]=true;
                pre=cur;
                cur=G[cur][nxt];
                loop.push_back(ps[cur]);
            }
            loops[edges[{pre,cur}]].push_back(loop);
        }
    }
    vector<int> checked(m);
    rep(i,n){
        
        rep(j,m){
            for(auto pol : loops[j]){
                if(included(ps[i],pol)){
                    for(auto to : G[i]){
                        if(edges[{i,to}]!=j){
                            ans[edges[{i,to}]]=0;
                        }
                    }
                }
            }
        }
    }
    int Ans=0;
    rep(i,m)Ans+=ans[i];
    cout<<Ans<<endl;

    return 0;
}


Measured memory_bytes: 3708