#include <bits/stdc++.h>
using namespace std;
int intcmp(const void *v1, const void *v2) { return *(int *)v1 - *(int *)v2; }
map<long long, int> p;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
struct segM {
  long long x1, x2;
  long long y1, y2;
  long long easycnt() {
    long long derx = abs(x1 - x2);
    long long dery = abs(y1 - y2);
    if (derx == 0 || dery == 0) return derx + dery + 1;
    long long gcdres = gcd(derx, dery);
    return gcdres + 1;
  }
};
segM s[1010];
int n;
bool samesign(long long v1, long long v2) {
  if (v1 > 0 && v2 > 0) return true;
  if (v1 < 0 && v2 < 0) return true;
  return false;
}
bool testinter(long long v1x1, long long v1y1, long long v1x2, long long v1y2,
               long long v2x1, long long v2y1, long long v2x2, long long v2y2,
               long long &resx, long long &resy) {
  long long a1 = v1y2 - v1y1;
  long long b1 = v1x2 - v1x1;
  long long c1 = -(a1 * v1x1 - b1 * v1y1);
  long long a2 = v2y2 - v2y1;
  long long b2 = v2x2 - v2x1;
  long long c2 = -(a2 * v2x1 - b2 * v2y1);
  long long xU = c1 * b2 - c2 * b1;
  long long yU = c1 * a2 - c2 * a1;
  long long D = a2 * b1 - a1 * b2;
  if (D == 0) return false;
  if (xU % D != 0 || yU % D != 0) return false;
  resx = xU / D;
  resy = yU / D;
  if (samesign(v1x1 - resx, v1x2 - resx)) return false;
  if (samesign(v2x1 - resx, v2x2 - resx)) return false;
  if (samesign(v1y1 - resy, v1y2 - resy)) return false;
  if (samesign(v2y1 - resy, v2y2 - resy)) return false;
  return true;
}
long long mysqrt(long long v) {
  long long ret = sqrt(v - 2);
  long long i = 0;
  for (i = ret; i < ret + 4; i++)
    if (i * i == v) return i;
  return -1;
}
int main() {
  cin >> n;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    scanf("%lld %lld %lld %lld", &s[i].x1, &s[i].y1, &s[i].x2, &s[i].y2);
    ans += s[i].easycnt();
  }
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      long long interX = 0, interY = 0;
      bool ok = testinter(s[i].x1, s[i].y1, s[i].x2, s[i].y2, s[j].x1, s[j].y1,
                          s[j].x2, s[j].y2, interX, interY);
      if (ok) {
        long long ec = (interX + 1000000) * 2000010 + (interY + 1000000);
        p[ec]++;
      }
    }
  }
  for (auto item : p) {
    ans -= (mysqrt(1 + 8 * item.second) - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
