#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
struct pt {
  long double x;
  long double y;
  pt() {}
  pt(long long x, long long y) {
    this->x = x;
    this->y = y;
  }
};
struct segment {
  long double cof;
  long double X;
  long double B;
  pt p1, p2;
  segment() {}
  segment(pt a, pt b) {
    this->p1 = a;
    this->p2 = b;
    if (a.x == b.x) {
      cof = 1;
      X = -a.x;
      B = 0;
    } else {
      cof = -(long double)(a.y - b.y) / (a.x - b.x);
      B = 1;
      X = -(long double)(a.x * cof) - a.y;
    }
  }
  pair<bool, pt> intersec(segment s) {
    pt p = pt(0, 0);
    if (paralelo(s))
      return {false, p};
    else {
      p.x =
          (s.B * this->X - this->B * s.X) / (s.cof * this->B - this->cof * s.B);
      if (fabs(this->B) > 0.0000001)
        p.y = -(this->cof * p.x + this->X);
      else
        p.y = -(s.cof * p.x + s.X);
      if ((fabs(floor(p.y) - p.y) < 0.0000001 ||
           fabs(ceil(p.y) - p.y) < 0.0000001) &&
          (fabs(floor(p.x) - p.x) < 0.0000001 ||
           fabs(ceil(p.x) - p.x) < 0.0000001)) {
        p.y = round(p.y);
        p.x = round(p.x);
        if ((p.y >= min(p1.y, p2.y) && p.y <= max(p1.y, p2.y)) &&
            (p.x >= min(p1.x, p2.x) && p.x <= max(p1.x, p2.x)) &&
            (p.y >= min(s.p1.y, s.p2.y) && p.y <= max(s.p1.y, s.p2.y)) &&
            (p.x >= min(s.p1.x, s.p2.x) && p.x <= max(s.p1.x, s.p2.x)))
          return {true, p};
        else
          return {false, p};
      } else
        return {false, p};
    }
  }
  bool paralelo(segment s) {
    return (fabs(s.cof - this->cof) < 0.0000001) &&
           (fabs(s.B - this->B) < 0.0000001);
  }
};
int main() {
  int n;
  cin >> n;
  long long total = 0;
  vector<segment> segments;
  map<long long, long long> nums;
  map<pair<long long, long long>, long long> intersecs;
  for (int i = 1; i <= 10000; i++) nums[i * (i + 1) / 2] = i;
  for (int i = 0; i < n; i++) {
    int xa, ya, xb, yb;
    cin >> xa >> ya >> xb >> yb;
    pt p1 = pt(xa, ya);
    pt p2 = pt(xb, yb);
    segment s = segment(p1, p2);
    total += gcd(abs(p1.x - p2.x), abs(p1.y - p2.y)) + 1;
    segments.push_back(s);
  }
  int cont = 0;
  for (int i = 0; i < segments.size(); i++) {
    for (int k = i + 1; k < segments.size(); k++) {
      pair<bool, pt> ans = segments[i].intersec(segments[k]);
      if (ans.first == true and k != i) {
        intersecs[{ans.second.x, ans.second.y}] += 1;
        total -= 1;
        cont += 1;
      }
    }
  }
  for (map<pair<long long, long long>, long long>::iterator it =
           intersecs.begin();
       it != intersecs.end(); it++) {
    total += (it->second - nums[it->second]);
  }
  cout << total;
}
