#include <bits/stdc++.h>
using namespace std;
const int maxN = 1e3 + 11;
typedef int i_N[maxN];
int N;
pair<int, int> A[maxN], B[maxN];
map<pair<long long, long long>, int> mp;
struct line {
  long long A, B, C;
  line(pair<int, int> P, pair<int, int> Q) {
    A = P.second - Q.second;
    B = Q.first - P.first;
    C = -(A * P.first + B * P.second);
  }
  bool parallel(const line& other) { return A * other.B == B * other.A; }
};
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
bool contain(pair<int, int> P, pair<int, int> Q,
             pair<long long, long long> point) {
  if (min(P.first, Q.first) > point.first ||
      point.first > max(P.first, Q.first))
    return false;
  if (min(P.second, Q.second) > point.second ||
      point.second > max(P.second, Q.second))
    return false;
  return true;
}
int main() {
  cin >> N;
  for (int i = 1; i <= N; i++)
    cin >> A[i].first >> A[i].second >> B[i].first >> B[i].second;
  int ans = 0;
  for (int i = 1; i <= N; i++) {
    int x = B[i].first - A[i].first, y = B[i].second - A[i].second;
    ans += abs(gcd(x, y)) + 1;
  }
  for (int i = 1; i <= N - 1; i++)
    for (int j = i + 1; j <= N; j++) {
      line l1(A[i], B[i]), l2(A[j], B[j]);
      if (l1.parallel(l2)) continue;
      pair<long long, long long> p;
      if (l1.B == 0) {
        if (l1.C % l1.A) continue;
        long long x = -l1.C / l1.A;
        if (-(l2.C + l2.A * x) % l2.B) continue;
        long long y = -(l2.C + l2.A * x) / l2.B;
        p = pair<long long, long long>(x, y);
        if (!contain(A[i], B[i], p) || !contain(A[j], B[j], p)) continue;
        mp[p]++;
      } else {
        if ((-l2.C * l1.B + l2.B * l1.C) % (l2.A * l1.B - l2.B * l1.A))
          continue;
        long long x =
            (-l2.C * l1.B + l2.B * l1.C) / (l2.A * l1.B - l2.B * l1.A);
        if ((l1.C + l1.A * x) % l1.B) continue;
        long long y = -(l1.C + l1.A * x) / l1.B;
        p = pair<long long, long long>(x, y);
        if (!contain(A[i], B[i], p) || !contain(A[j], B[j], p)) continue;
        mp[p]++;
      }
      pair<long long, long long> tmp = p;
      tmp.second++;
    }
  for (map<pair<long long, long long>, int>::iterator it = mp.begin();
       it != mp.end(); it++) {
    int t = it->second;
    t *= 2;
    int tmp = sqrt(t);
    while (tmp * (tmp - 1) < t) tmp++;
    while (tmp * (tmp - 1) > t) tmp--;
    ans -= tmp - 1;
  }
  cout << ans;
}
