#include <bits/stdc++.h>
using namespace std;
struct seg_t {
  long long ax, ay, bx, by, mx, my, k;
};
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;
}
bool intersect(const seg_t& s1, const seg_t& s2, long long& x, long long& y) {
  long long d = s1.mx * s2.my - s1.my * s2.mx;
  if (d == 0) return false;
  long long xn = s1.mx * s2.mx * (s1.ay - s2.ay) + s1.mx * s2.my * s2.ax -
                 s1.my * s2.mx * s1.ax;
  long long yn = s1.my * s2.my * (s2.ax - s1.ax) + s1.mx * s2.my * s1.ay -
                 s1.my * s2.mx * s2.ay;
  if ((xn % d) || (yn % d)) return false;
  x = xn / d;
  y = yn / d;
  if (x < max(min(s1.ax, s1.bx), min(s2.ax, s2.bx))) return false;
  if (x > min(max(s1.ax, s1.bx), max(s2.ax, s2.bx))) return false;
  if (y < max(min(s1.ay, s1.by), min(s2.ay, s2.by))) return false;
  if (y > min(max(s1.ay, s1.by), max(s2.ay, s2.by))) return false;
  return true;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<seg_t> s(n);
  long long r = 0;
  for (seg_t& si : s) {
    cin >> si.ax >> si.ay >> si.bx >> si.by;
    if (si.ax > si.bx) {
      swap(si.ax, si.bx);
      swap(si.ay, si.by);
    }
    si.mx = si.bx - si.ax;
    si.my = si.by - si.ay;
    si.k = gcd(abs(si.mx), abs(si.my));
    si.mx /= si.k;
    si.my /= si.k;
    r += si.k + 1;
  }
  map<pair<int, int>, set<int>> t;
  long long x, y;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      if (intersect(s[i], s[j], x, y)) {
        t[{x, y}].insert(i);
        t[{x, y}].insert(j);
      }
    }
  }
  for (const auto& ti : t) r -= ti.second.size() - 1;
  cout << r << endl;
  return 0;
}
