#include <bits/stdc++.h>
using namespace std;
struct sPoint {
  long long x, y;
};
struct sSegment {
  sPoint p[2];
};
long long IntAbs(long long x) { return (x < 0) ? -x : x; }
long long GCD(long long a, long long b) {
  if (a < b) return GCD(b, a);
  if (b == 0) return a;
  return GCD(b, a % b);
}
void GetSegmentInfo(const sSegment& s, long long& vx, long long& vy,
                    long long& cnt) {
  long long dx = s.p[1].x - s.p[0].x;
  long long dy = s.p[1].y - s.p[0].y;
  cnt = GCD(IntAbs(dx), IntAbs(dy));
  vx = dx / cnt;
  vy = dy / cnt;
}
long long VectorProduct(const sPoint& p1, const sPoint& p2, const sPoint& p3) {
  return p1.x * p2.y + p2.x * p3.y + p3.x * p1.y - p1.x * p3.y - p2.x * p1.y -
         p3.x * p2.y;
}
bool IntersectHelper(const sSegment& s1, const sSegment& s2) {
  long long vp1 = VectorProduct(s1.p[0], s1.p[1], s2.p[0]);
  long long vp2 = VectorProduct(s1.p[0], s1.p[1], s2.p[1]);
  return ((vp1 <= 0) && (vp2 >= 0)) || ((vp1 >= 0) && (vp2 <= 0));
}
bool Intersect(const sSegment& s1, const sSegment& s2) {
  return IntersectHelper(s1, s2) && IntersectHelper(s2, s1);
}
bool operator<(const sPoint& p1, const sPoint& p2) {
  return p1.x < p2.x || ((p1.x == p2.x) & (p1.y < p2.y));
}
void Task1036E() {
  size_t n;
  cin >> n;
  vector<sSegment> v(n);
  vector<long long> vx(n), vy(n), cnt(n);
  long long res = 0;
  for (size_t i = 0; i < n; ++i) {
    cin >> v[i].p[0].x >> v[i].p[0].y >> v[i].p[1].x >> v[i].p[1].y;
    GetSegmentInfo(v[i], vx[i], vy[i], cnt[i]);
    res += cnt[i] + 1;
  }
  vector<sPoint> p;
  for (size_t i = 0; i < n; ++i) {
    p.clear();
    for (size_t j = i + 1; j < n; ++j) {
      if (!Intersect(v[i], v[j])) continue;
      long long b = 0, e = cnt[i];
      while (b < e) {
        long long m = (b + e) / 2;
        sSegment tmp;
        tmp.p[0].x = v[i].p[0].x + vx[i] * b;
        tmp.p[0].y = v[i].p[0].y + vy[i] * b;
        tmp.p[1].x = v[i].p[0].x + vx[i] * m;
        tmp.p[1].y = v[i].p[0].y + vy[i] * m;
        if (Intersect(v[j], tmp))
          e = m;
        else
          b = m + 1;
      }
      sSegment tmp;
      tmp.p[0].x = v[i].p[0].x + vx[i] * b;
      tmp.p[0].y = v[i].p[0].y + vy[i] * b;
      tmp.p[1].x = v[i].p[0].x + vx[i] * b;
      tmp.p[1].y = v[i].p[0].y + vy[i] * b;
      if (Intersect(v[j], tmp)) p.push_back(tmp.p[0]);
    }
    make_heap(p.begin(), p.end());
    sort_heap(p.begin(), p.end());
    for (size_t j = 0; j < p.size(); ++j)
      if (j == 0 || p[j].x != p[j - 1].x || p[j].y != p[j - 1].y) --res;
  }
  cout << res;
}
int main() {
  Task1036E();
  return 0;
}
