#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
struct Point {
  long long x, y;
};
struct Param {
  long long a, b, c;
};
inline Param GetParam(Point A1, Point A2) {
  long long a = A2.y - A1.y;
  long long b = -(A2.x - A1.x);
  long long c = -a * A1.x - b * A1.y;
  return Param{a, b, c};
}
inline long long Abs(long long x) { return x > 0 ? x : -x; }
bool no_sol;
inline Point GetIntersect(Point A1, Point A2, Point B1, Point B2) {
  Param p1 = GetParam(A1, A2), p2 = GetParam(B1, B2);
  long long d = p1.a * p2.b - p2.a * p1.b;
  if (!d) return no_sol = true, Point{114514, 114514};
  long long x0 = (p1.b * p2.c - p2.b * p1.c);
  long long y0 = (p2.a * p1.c - p1.a * p2.c);
  if ((long long)x0 % (long long)d != 0)
    return no_sol = true, Point{114514, 114514};
  if ((long long)y0 % (long long)d != 0)
    return no_sol = true, Point{114514, 114514};
  return Point{x0 / d, y0 / d};
}
bool CheckInIntervalX(Point P, Point A1, Point A2) {
  long long l = min(A1.x, A2.x), r = max(A1.x, A2.x);
  return l <= P.x && P.x <= r;
}
bool CheckInIntervalY(Point P, Point A1, Point A2) {
  long long l = min(A1.y, A2.y), r = max(A1.y, A2.y);
  return l <= P.y && P.y <= r;
}
long long gcd(long long x, long long y) { return y == 0 ? x : gcd(y, x % y); }
Point A[1000005], B[1000005];
pair<long long, long long> points[1000005];
long long tot;
int main() {
  long long n = read();
  for (long long i = 1; i <= n; ++i) {
    A[i].x = read(), A[i].y = read();
    B[i].x = read(), B[i].y = read();
  }
  long long ans = 0;
  for (long long i = 1; i <= n; ++i) {
    long long on_line =
        gcd((long long)Abs(A[i].x - B[i].x), (long long)Abs(A[i].y - B[i].y)) +
        1;
    tot = 0;
    for (long long j = 1; j < i; ++j) {
      no_sol = false;
      Point P = GetIntersect(A[j], B[j], A[i], B[i]);
      if (no_sol) continue;
      if ((!CheckInIntervalX(P, A[i], B[i])) ||
          (!CheckInIntervalX(P, A[j], B[j])))
        continue;
      if ((!CheckInIntervalY(P, A[i], B[i])) ||
          (!CheckInIntervalY(P, A[j], B[j])))
        continue;
      points[++tot].first = (long long)P.x, points[tot].second = (long long)P.y;
    }
    sort(points + 1, points + 1 + tot);
    tot = unique(points + 1, points + 1 + tot) - points - 1;
    ans += on_line - tot;
  }
  printf("%lld\n", ans);
  return 0;
}
