#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1100;
const long long BAD = 1e18;
int N;
int x[MAXN], y[MAXN], x2[MAXN], y2[MAXN];
complex<long long> A[MAXN], B[MAXN];
int gcf(int a, int b) {
  if (b == 0) return a;
  return gcf(b, a % b);
}
int npoint(int a) { return gcf(abs(x[a] - x2[a]), abs(y[a] - y2[a])) + 1; }
long long cross(complex<long long> left, complex<long long> right) {
  return imag(conj(left) * right);
}
long long ang_cross(complex<long long> a, complex<long long> b,
                    complex<long long> c) {
  return cross(b - a, c - a);
}
long long inter(int l, int r) {
  long long c1 = ang_cross(A[l], B[l], A[r]), c2 = ang_cross(A[l], B[l], B[r]);
  long long c3 = ang_cross(A[r], B[r], A[l]), c4 = ang_cross(A[r], B[r], B[l]);
  if (c1 < 0 && c2 < 0) return BAD;
  if (c1 > 0 && c2 > 0) return BAD;
  if (c3 < 0 && c4 < 0) return BAD;
  if (c3 > 0 && c4 > 0) return BAD;
  complex<long long> cp = c1 * B[r] - c2 * A[r];
  long long delta = c1 - c2;
  if (cp.real() % delta != 0 || cp.imag() % delta != 0) return BAD;
  return cp.real() / delta * (long long)1e7 + cp.imag() / delta;
}
set<long long> mm;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> N;
  long long ans = 0;
  for (int i = 0; i < N; i++) {
    cin >> x[i] >> y[i] >> x2[i] >> y2[i];
    ans += npoint(i);
    A[i] = complex<long long>(x[i], y[i]);
    B[i] = complex<long long>(x2[i], y2[i]);
  }
  for (int i = 0; i < N; i++) {
    mm.clear();
    for (int j = i + 1; j < N; j++) {
      long long v = inter(i, j);
      if (v < 1e15) mm.insert(v);
    }
    ans -= mm.size();
  }
  cout << ans << "\n";
}
