시간 제한메모리 제한제출정답맞힌 사람정답 비율
10 초 (추가 시간 없음) 1024 MB100866.383%

문제

Peter is bored during his operating systems class, so he draws doodles on a sheet of paper.  He feels like drawing abstract art using his ruler: he draws line segments by choosing two points in the plane and connecting them. Lots of them.

Can you write a program that counts the number of distinct points at which the line segments he drew intersect or touch?

입력

The first line in the input contains an integer $n$ ($1 \le n \le 1\,000$) which is the number of lines.  The following $n$ lines contain four integers $x_0 \ \  y_0 \ \ x_1 \ \  y_1$ ($-1\,000\,000 \le x_0, \ y_0, \ x_1, \ y_1 \le 1\,000\,000$. Lines have non-zero length, i.e., the two points will be distinct: $x_0 \ne x_1$ or $y_0 \ne y_1$ or both.

출력

Output the number of distinct points for which there is at least one pair of line segments that intersects or touches at this point.

Ignore those intersections points in your count that are created by line segments that intersect or touch at more than one point (i.e. overlapping segments).

You may further assume that if two line segments touch exactly at their endpoints, the three points involved are not collinear.

예제 입력 1

3
1 3 9 5
2 2 6 8
4 8 9 3

예제 출력 1

3

예제 입력 2

3
5 2 7 10
7 4 4 10
2 4 10 8

예제 출력 2

1

예제 입력 3

3
2 1 6 5
2 5 5 4
5 1 7 7

예제 출력 3

1