#include <bits/stdc++.h>
using namespace std;
inline long long pos_mod(long long i, long long n) { return (i % n + n) % n; }
vector<vector<int>> divisors(int upper) {
  vector<vector<int>> res(upper + 1);
  for (int i = 1; i <= upper; i++) {
    for (int j = i; j <= upper; j += i) {
      res[j].push_back(i);
    }
  }
  return res;
}
vector<int> divisors_count(int upper) {
  vector<int> res(upper + 1);
  for (int i = 1; i <= upper; i++) {
    for (int j = i; j <= upper; j += i) {
      res[j]++;
    }
  }
  return res;
}
template <typename T>
pair<T, pair<T, T>> euclidean_extended(T a, T b) {
  T x1 = 1, x2 = 0, y1 = 0, y2 = 1;
  int a_mult = 1;
  if (a < 0) {
    a *= -1;
    a_mult *= -1;
  }
  int b_mult = 1;
  if (b < 0) {
    b *= -1;
    b_mult *= -1;
  }
  T q, r;
  while (b != 0) {
    T q = a / b;
    T r = a - b * q;
    a = b;
    b = r;
    x1 = x1 - q * x2;
    swap(x1, x2);
    y1 = y1 - q * y2;
    swap(y1, y2);
  };
  return {a, {a_mult * x1, b_mult * y1}};
}
pair<bool, pair<double, double>> segment_intersection(double x1, double y1,
                                                      double x2, double y2,
                                                      double x3, double y3,
                                                      double x4, double y4) {
  double a1, b1, c1, a2, b2, c2, a3, b3, c3;
  double eps = 0.00000001;
  a1 = x2 - x1;
  b1 = y2 - y1;
  swap(a1, b1);
  a1 *= -1;
  c1 = -a1 * x1 - b1 * y1;
  a2 = x4 - x3;
  b2 = y4 - y3;
  swap(a2, b2);
  a2 *= -1;
  c2 = -a2 * x3 - b2 * y3;
  a3 = b1 * c2 - c1 * b2;
  b3 = -(a1 * c2 - c1 * a2);
  c3 = a1 * b2 - b1 * a2;
  if (abs(c3) < eps) {
    return {false, {0, 0}};
  } else {
    double x = a3 / c3;
    double y = b3 / c3;
    if (x > min(x1, x2) - eps && x < max(x1, x2) + eps &&
        x > min(x3, x4) - eps && x < max(x3, x4) + eps &&
        y > min(y1, y2) - eps && y < max(y1, y2) + eps &&
        y > min(y3, y4) - eps && y < max(y3, y4) + eps) {
      return {true, {x, y}};
    } else {
      return {false, {0, 0}};
    }
  }
}
struct l {
  int x1, y1, x2, y2;
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<l> lines;
  long long cnt = 0;
  for (int i = 0; i < (n); i++) {
    int ax, ay, bx, by;
    cin >> ax >> ay >> bx >> by;
    lines.push_back({ax, ay, bx, by});
    int x = abs(ax - bx);
    int y = abs(ay - by);
    if (x == 0) {
      cnt += y + 1;
    } else if (y == 0) {
      cnt += x + 1;
    } else {
      int g = euclidean_extended<int>(x, y).first;
      cnt += g + 1;
    }
  }
  map<pair<int, int>, int> col;
  for (int i = 0; i < n; i++) {
    set<pair<int, int>> my;
    for (int j = i + 1; j < n; j++) {
      auto l1 = lines[i];
      auto l2 = lines[j];
      auto p = segment_intersection(l1.x1, l1.y1, l1.x2, l1.y2, l2.x1, l2.y1,
                                    l2.x2, l2.y2);
      if (p.first) {
        double x = p.second.first;
        double y = p.second.second;
        int xr = (int)round(x);
        int yr = (int)round(y);
        if (my.count({xr, yr})) continue;
        double eps = 0.000000001;
        if (std::abs(x - xr) < eps && std::abs(y - yr) < eps) {
          col[{xr, yr}]++;
          my.insert({xr, yr});
        }
      }
    }
  }
  for (auto p : col) {
    cnt -= p.second;
  }
  cout << cnt << endl;
}
