#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 1e3 + 100;
struct Point {
  long long x;
  long long y;
  Point() {}
};
struct Vector {
  long long x;
  long long y;
  Vector() {}
  Vector(Point a, Point b) {
    x = b.x - a.x;
    y = b.y - a.y;
  }
};
struct Segm {
  Point a;
  Point b;
  Segm() {}
};
struct Line {
  long long a;
  long long b;
  long long c;
  Line() {}
  Line(Point p1, Point p2) {
    a = p1.y - p2.y;
    b = p2.x - p1.x;
    c = -a * p1.x - b * p1.y;
  }
};
long long gcd(long long a, long long b) {
  a = abs(a);
  b = abs(b);
  if (a < b) swap(a, b);
  while (b != 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}
long long operator*(Vector a, Vector b) { return (a.x * b.x + a.y * b.y); }
long long n;
Segm mas[MAXN];
Line ml[MAXN];
long long ans = 0;
map<pair<long long, long long>, long long> mp;
void Per(long long i, long long j) {
  long long x = 0;
  long long y = 0;
  if ((ml[i].b * ml[j].a - ml[j].b * ml[i].a) == 0) {
    return;
  }
  if ((ml[j].c * ml[i].a - ml[i].c * ml[j].a) %
          (ml[i].b * ml[j].a - ml[j].b * ml[i].a) ==
      0) {
    y = ((ml[j].c * ml[i].a - ml[i].c * ml[j].a) /
         (ml[i].b * ml[j].a - ml[j].b * ml[i].a));
  } else {
    return;
  }
  if ((ml[j].c * ml[i].b - ml[i].c * ml[j].b) %
          (ml[i].a * ml[j].b - ml[j].a * ml[i].b) ==
      0) {
    x = ((ml[j].c * ml[i].b - ml[i].c * ml[j].b) /
         (ml[i].a * ml[j].b - ml[j].a * ml[i].b));
  } else {
    return;
  }
  if ((abs(x) > 1e6) || (abs(y) > 1e6)) {
    return;
  }
  Point a;
  a.x = x;
  a.y = y;
  if ((Vector(a, mas[i].a) * Vector(a, mas[i].b) <= 0) &&
      (Vector(a, mas[j].a) * Vector(a, mas[j].b) <= 0)) {
    mp[make_pair(x, y)]++;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  cin >> n;
  for (long long i = 0; i < n; ++i) {
    cin >> mas[i].a.x >> mas[i].a.y >> mas[i].b.x >> mas[i].b.y;
    long long a = abs(mas[i].a.x - mas[i].b.x);
    long long b = abs(mas[i].a.y - mas[i].b.y);
    long long c = gcd(a, b);
    ans += (c + 1);
    ml[i] = Line(mas[i].a, mas[i].b);
  }
  for (long long i = 0; i < n; ++i) {
    for (long long j = i + 1; j < n; ++j) {
      Per(i, j);
    }
  }
  for (auto e : mp) {
    long long l = 1;
    while ((l * (l - 1)) / 2LL < e.second) {
      l++;
    }
    ans -= l - 1;
  }
  cout << ans << endl;
  return 0;
}
