#include <fstream>
#include <cmath>
#define NMAX 500
#define int double
#define EPS 0.00001
using namespace std;
ifstream cin ("geometry.in");
ofstream cout ("geometry.out");
struct dreapta {
int x1, y1, x2, y2;
};
dreapta v[NMAX + 1];
double get_dist(int x1, int y1, int x2, int y2) {
return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
bool is_in_segment(int x1, int y1, dreapta A) { /// stiu ca e segment
cout << get_dist(x1, y1, A.x1, A.y1) + get_dist(x1, y1, A.x2, A.y2) - get_dist(A.x1, A.x1, A.x2, A.y2) << "\n";
return get_dist(x1, y1, A.x1, A.y1) + get_dist(x1, y1, A.x2, A.y2) == get_dist(A.x1, A.x1, A.x2, A.y2);
}
bool solve(dreapta A, dreapta B) {
double aA, bA, aB, bB, x1, y1;
if (B.x1 == B.x2) {
dreapta aux = A;
A = B;
B = aux;
}
if (A.x1 == A.x2) {
if (B.x1 == B.x2) {
if (A.x1 == B.x1) {
if (A.y2 >= B.y1 && A.y2 <= B.y2)
return 1;
else if (B.y2 >= A.y1 && B.y2 <= A.y2)
return 1;
else
return 0;
}
else
return 0;
}
else {
aB = (B.y1 - B.y2) / (B.x1 - B.x2);
bB = B.y1 - aB * B.x1;
x1 = A.x1;
y1 = x1 * aB + bB;
//cout << is_in_segment(x1, y1, A) << " " << is_in_segment(x1, y1, B) << "\n";
return is_in_segment(x1, y1, A) & is_in_segment(x1, y1, B);
}
}
aA = (A.y1 - A.y2) / (A.x1 - A.x2);
bA = A.y1 - aA * A.x1;
aB = (B.y1 - B.y2) / (B.x1 - B.x2);
bB = B.y1 - aB * B.x1;
x1 = (bB - bA) / (aA - aB);
y1 = x1 * aA + bA;
//cout << x1 << " " << y1 << "\n";
return is_in_segment(x1, y1, A) & is_in_segment(x1, y1, B);
}
signed main() {
int n, sol;
signed i, j;
cin >> n;
for (i = 0; i < n; i++) {
cin >> v[i].x1 >> v[i].y1 >> v[i].x2 >> v[i].y2;
}
sol = 0;
for (i = 0; i < n; i++) {
for (j = i + 1; j < n; j++) {
sol += solve(v[i], v[j]);
}
}
cout << sol;
return 0;
}