#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
struct seg {
  int xa, xb, ya, yb;
};
int n;
vector<seg> s;
bool in(seg p, int x, int y) {
  if (p.xa > p.xb) swap(p.xa, p.xb);
  if (p.ya > p.yb) swap(p.ya, p.yb);
  return p.xa <= x && x <= p.xb && p.ya <= y && y <= p.yb;
}
bool intersect(seg a, seg b, int &x, int &y) {
  long long A1 = a.yb - a.ya, B1 = a.xa - a.xb, C1 = A1 * a.xa + B1 * a.ya;
  long long A2 = b.yb - b.ya, B2 = b.xa - b.xb, C2 = A2 * b.xa + B2 * b.ya;
  long long D = A1 * B2 - A2 * B1;
  long long Dx = C1 * B2 - C2 * B1;
  long long Dy = A1 * C2 - A2 * C1;
  if (!D) return 0;
  if (Dx % D != 0 || Dy % D != 0) return 0;
  x = Dx / D;
  y = Dy / D;
  if (!in(a, x, y) || !in(b, x, y)) return 0;
  return 1;
}
int main() {
  while (cin >> n) {
    s.resize(n);
    long long ans = 0;
    for (int i = 0; i < n; ++i) {
      cin >> s[i].xa >> s[i].ya >> s[i].xb >> s[i].yb;
      int a = abs(s[i].xa - s[i].xb);
      int b = abs(s[i].ya - s[i].yb);
      if (a == 0 && b == 0)
        ans += 1LL;
      else
        ans = ans + (long long)(gcd(a, b) + 1LL);
    }
    for (int i = 0; i < n; ++i) {
      set<pair<int, int>> se;
      for (int j = 0; j < i; ++j) {
        int x, y;
        if (intersect(s[i], s[j], x, y)) {
          se.insert({x, y});
        }
      }
      ans -= se.size();
    }
    cout << ans << endl;
  }
  return 0;
}
