#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0;
  char c = getchar();
  bool f = 0;
  for (; c > '9' || c < '0'; f = c == '-', c = getchar())
    ;
  for (; c >= '0' && c <= '9'; x = (x << 1) + (x << 3) + c - '0', c = getchar())
    ;
  return f ? -x : x;
}
inline void write(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x >= 10) write(x / 10);
  putchar(x % 10 + 48);
}
const int eps = 0;
int dcmp(long long x) {
  if (abs(x) <= eps) return 0;
  return x > eps ? 1 : -1;
}
struct Point {
  long long x, y;
  Point() {}
  Point(long long x_, long long y_) { x = x_, y = y_; }
  bool operator==(const Point &B) const {
    return dcmp(x - B.x) == 0 && dcmp(y - B.y) == 0;
  }
  bool operator<(const Point &B) const {
    return dcmp(x - B.x) == 0 ? y < B.y : x < B.x;
  }
};
struct Line {
  Point p;
  Point v;
  Line() {}
  Line(Point p_, Point v_) {
    p = p_;
    v = v_;
  }
};
Point operator-(Point A, Point B) { return Point(A.x - B.x, A.y - B.y); }
Point operator+(Point A, Point B) { return Point(A.x + B.x, A.y + B.y); }
long long Cross(Point A, Point B) { return A.x * B.y - B.x * A.y; }
Point operator*(Point A, long long b) { return Point(A.x * b, A.y * b); }
Point operator/(Point A, long long b) { return Point(A.x / b, A.y / b); }
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
bool check(double A, double B, double C, double D) {
  if (dcmp(A - B) == 1) swap(A, B);
  if (dcmp(C - D) == 1) swap(C, D);
  return dcmp(D - A) != -1 && dcmp(B - C) != -1;
}
int IsIntersection(Line A, Line B) {
  Point a1 = A.p, a2 = A.p + A.v;
  Point b1 = B.p, b2 = B.p + B.v;
  if (min(a1.x, a2.x) > max(b1.x, b2.x) || min(b1.x, b2.x) > max(a1.x, a2.x) ||
      min(a1.y, a2.y) > max(b1.y, b2.y) || min(b1.y, b2.y) > max(a1.y, a2.y))
    return 0;
  long long c1 = Cross(a2 - a1, b1 - a1), c2 = Cross(a2 - a1, b2 - a1);
  long long c3 = Cross(b2 - b1, a1 - b1), c4 = Cross(b2 - b1, a2 - b1);
  if ((c1 > 0 && c2 > 0) || (c3 > 0 && c4 > 0)) return 0;
  if ((c1 < 0 && c2 < 0) || (c3 < 0 && c4 < 0)) return 0;
  if ((c1 == 0 && c2 == 0) || (c3 == 0 && c4 == 0)) return -1;
  return 1;
}
bool GetIntersection(Line A, Line B, Point &p) {
  long long k1 = Cross(B.p - A.p, B.v), k2 = Cross(A.v, B.v);
  if (abs(A.v.x) * abs(k1) % abs(k2) != 0 ||
      abs(A.v.y) * abs(k1) % abs(k2) != 0)
    return 0;
  p = A.p + A.v * k1 / k2;
  return 1;
}
const int N = 1000 + 10;
int n;
Line l[N];
long long ans;
map<Point, unordered_set<int> > Map;
int main() {
  n = read();
  for (int i = 1; i <= n; ++i) {
    Point p1, p2;
    p1.x = read(), p1.y = read();
    p2.x = read(), p2.y = read();
    Point v = p2 - p1;
    l[i] = Line(p1, v);
    ans += gcd(abs(v.x), abs(v.y)) + 1;
  }
  for (int i = 1; i <= n; ++i)
    for (int j = i + 1; j <= n; ++j)
      if (IsIntersection(l[i], l[j])) {
        Point p;
        if (GetIntersection(l[i], l[j], p)) {
          Map[p].insert(i);
          Map[p].insert(j);
        }
      }
  for (auto &s : Map) {
    ans -= s.second.size() - 1;
  }
  write(ans);
  puts("");
}
