#include <bits/stdc++.h>
using namespace std;
struct Point {
  long long x, y;
};
void sc(Point& t) { scanf("%I64d%I64d", &t.x, &t.y); }
double mult(Point a, Point b, Point c) {
  return (a.x - c.x) * (b.y - c.y) - (b.x - c.x) * (a.y - c.y);
}
bool intersect(Point aa, Point bb, Point cc, Point dd) {
  if (max(aa.x, bb.x) < min(cc.x, dd.x)) return false;
  if (max(aa.y, bb.y) < min(cc.y, dd.y)) return false;
  if (max(cc.x, dd.x) < min(aa.x, bb.x)) return false;
  if (max(cc.y, dd.y) < min(aa.y, bb.y)) return false;
  if (mult(cc, bb, aa) * mult(bb, dd, aa) < 0) return false;
  if (mult(aa, dd, cc) * mult(dd, bb, cc) < 0) return false;
  return true;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
Point a[1010], b[1010];
bool solve(long long a1, long long b1, long long c1, long long a2, long long b2,
           long long c2, long long& x, long long& y) {
  if ((c1 * b2 - c2 * b1) % (a2 * b1 - a1 * b2) != 0)
    return false;
  else
    x = (c1 * b2 - c2 * b1) / (a2 * b1 - a1 * b2);
  if ((a2 * c1 - a1 * c2) % (a1 * b2 - a2 * b1) != 0)
    return false;
  else
    y = (a2 * c1 - a1 * c2) / (a1 * b2 - a2 * b1);
  return true;
}
bool its(Point a, Point b, Point c, Point d, Point& o) {
  if (solve(a.y - b.y, b.x - a.x, a.x * b.y - b.x * a.y, c.y - d.y, d.x - c.x,
            c.x * d.y - d.x * c.y, o.x, o.y)) {
    return true;
  } else
    return false;
}
long long gs(long long x) { return sqrt(2 * x); }
int main() {
  int n;
  long long ans = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    sc(a[i]);
    sc(b[i]);
    long long p = a[i].x - b[i].x, q = a[i].y - b[i].y;
    if (p < 0) p = -p;
    if (q < 0) q = -q;
    ans += gcd(p, q) + 1;
  }
  map<long long, long long> s;
  for (int i = 1; i < n; i++) {
    for (int j = i + 1; j <= n; j++) {
      if (!intersect(a[i], b[i], a[j], b[j])) continue;
      Point o;
      if (!its(a[i], b[i], a[j], b[j], o)) continue;
      if (s.find(o.x * 10000000 + o.y) == s.end()) {
        s[o.x * 10000000 + o.y] = 1;
      } else {
        s[o.x * 10000000 + o.y]++;
      }
    }
  }
  map<long long, long long>::iterator it;
  for (it = s.begin(); it != s.end(); it++) {
    ans -= gs(it->second);
  }
  printf("%I64d\n", ans);
  return 0;
}
