cho.sh
Notes
Loading...

Line Drawing

Time limit

2s

Memory limit

128 MB

Problem

Jungmun wants to draw N line segments on a two-dimensional plane. Segments that touch, overlap, or cross can be considered part of one connected line group. If segments are connected through a chain of other segments, they also belong to the same group.

Given the information for all N segments, determine how many separated line groups are needed to represent them.

Input

The first line contains the number of segments N (1 <= N <= 10,000).

Each of the next N lines contains four numbers x1, y1, x2, y2. They describe a segment from (x1, y1) to (x2, y2). Every coordinate is between 0 and 1000 inclusive and is given with at most two digits after the decimal point. Every segment has positive length.

Output

Print the number of separated line groups.