#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;
const double pi = acos(-1.0);
const int INF = 0x3f3f3f3f;
struct Line
{
double x1,y1,x2,y2;
}node[105];
bool solve(Line a, Line b)//叉积判断两线段是否相交
{
if (((a.x1-b.x1)*(a.y2-b.y1)-(a.x2-b.x1)*(a.y1-b.y1))*((a.x1-b.x2)*(a.y2-b.y2)-(a.x2-b.x2)*(a.y1-b.y2))>0)
return false;
if (((b.x1-a.x1)*(b.y2-a.y1)-(b.x2-a.x1)*(b.y1-a.y1))*((b.x1-a.x2)*(b.y2-a.y2)-(b.x2-a.x2)*(b.y1-a.y2))>0)
return false;
return true;
}
int main ()
{
int n;
while (scanf ("%d",&n),n)
{
for (int i=0; i<n; i++)
scanf ("%lf%lf%lf%lf",&node[i].x1,&node[i].y1,&node[i].x2,&node[i].y2);
int cnt = 0;
for (int i=0; i<n; i++)
{
for (int j=i+1; j<n; j++)
{
if (solve(node[i], node[j]))
cnt++;
}
}
printf ("%d
",cnt);
}
return 0;
}