#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (a < b) swap(a, b);
  while (b) {
    long long c = a % b;
    a = b;
    b = c;
  }
  return a;
}
struct seg {
  pair<long long, long long> a, b;
  seg(pair<long long, long long> x1, pair<long long, long long> x2)
      : a(x1), b(x2) {}
};
const int maxn = 1010;
vector<seg> v;
map<pair<long long, long long>, int> mapa;
long long cd[maxn];
int sgn(long long a) {
  if (a > 0) return 1;
  if (a < 0) return -1;
  return 0;
}
long long det(pair<long long, long long> a, pair<long long, long long> b,
              pair<long long, long long> c) {
  return (a.first * b.second + b.first * c.second + c.first * a.second -
          a.first * c.second - b.first * a.second - c.first * b.second);
}
pair<bool, pair<long long, long long> > checkn(int i, int j) {
  seg c = v[i];
  seg d = v[j];
  if (det(c.a, c.b, d.a) == 0 && min(c.a.first, c.b.first) <= d.a.first &&
      d.a.first <= max(c.a.first, c.b.first) &&
      min(c.a.second, c.b.second) <= d.a.second &&
      d.a.second <= max(c.a.second, c.b.second)) {
    return {true, d.a};
  }
  if (det(c.a, c.b, d.b) == 0 && min(c.a.first, c.b.first) <= d.b.first &&
      d.b.first <= max(c.a.first, c.b.first) &&
      min(c.a.second, c.b.second) <= d.b.second &&
      d.b.second <= max(c.a.second, c.b.second)) {
    return {true, d.b};
  }
  if (det(d.a, d.b, c.a) == 0 && min(d.a.first, d.b.first) <= c.a.first &&
      c.a.first <= max(d.a.first, d.b.first) &&
      min(d.a.second, d.b.second) <= c.a.second &&
      c.a.second <= max(d.a.second, d.b.second)) {
    return {true, c.a};
  }
  if (det(d.a, d.b, c.b) == 0 && min(d.a.first, d.b.first) <= c.b.first &&
      c.b.first <= max(d.a.first, d.b.first) &&
      min(d.a.second, d.b.second) <= c.b.second &&
      c.b.second <= max(d.a.second, d.b.second)) {
    return {true, c.b};
  }
  if (sgn(det(c.a, c.b, d.a)) * sgn(det(c.a, c.b, d.b)) >= 0 ||
      sgn(det(d.a, d.b, c.a)) * sgn(det(d.a, d.b, c.b)) >= 0) {
    return {false, {0, 0}};
  }
  long long le = 0, ri = cd[i];
  while (le < ri) {
    long long mid = (le + ri + 1) / 2;
    pair<long long, long long> e = c.a;
    e.first += (c.b.first - c.a.first) / cd[i] * mid;
    e.second += (c.b.second - c.a.second) / cd[i] * mid;
    if (sgn(det(d.a, d.b, c.a)) * sgn(det(d.a, d.b, e)) < 0) {
      ri = mid - 1;
    } else {
      le = mid;
    }
  }
  pair<long long, long long> e = c.a;
  e.first += (c.b.first - c.a.first) / cd[i] * le;
  e.second += (c.b.second - c.a.second) / cd[i] * le;
  if (det(d.a, d.b, e) == 0) return {true, e};
  return {false, {0, 0}};
}
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  long long res = 0;
  for (int i = 0; i < n; i++) {
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    v.push_back(seg({a, b}, {c, d}));
    cd[i] = gcd(abs(a - c), abs(b - d));
    res += cd[i] + 1;
  }
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      auto x = checkn(i, j);
      if (x.first) {
        pair<long long, long long> y = x.second;
        if (mapa.count(y))
          mapa[y]++;
        else
          mapa[y] = 1;
      }
    }
  }
  for (auto x : mapa) {
    int y = x.second;
    int z = sqrt(2 * y);
    while (z * (z - 1) / 2 != y) z++;
    res -= z - 1;
  }
  cout << res << "\n";
  return 0;
}
