#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;
template <typename T>
using vt = std::vector<T>;
template <typename T>
using vvt = vt<vt<T>>;
template <typename T>
using vvvt = vt<vvt<T>>;
using vi = vt<int>;
using vvi = vvt<int>;
using vvvi = vvvt<int>;
using vl = vt<ll>;
using vvl = vvt<ll>;
using vvvl = vvvt<ll>;
using vb = vt<bool>;
using vpii = vt<pii>;
static inline void Solve();
int main(int argc, char* argv[]) {
  {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
  };
  Solve();
  return 0;
}
ll gcd(ll x, ll y) {
  if (y == 0) return x;
  if (x % y == 0) return y;
  return gcd(y, x % y);
}
ll cnt_iterpoint(const vl& seg) {
  if (seg[0] == seg[2]) return abs(seg[3] - seg[1]) + 1;
  if (seg[1] == seg[3]) return abs(seg[2] - seg[0]) + 1;
  ll dx = abs(seg[2] - seg[0]), dy = abs(seg[3] - seg[1]);
  return 1 + gcd(dx, dy);
}
const pll INVALID_POINT = {-100000000, -100000000};
pll seg_iter(const vl& seg1, const vl& seg2) {
  if ((seg1[3] - seg1[1]) * (seg2[2] - seg2[0]) ==
      (seg2[3] - seg2[1]) * (seg1[2] - seg1[0])) {
    return INVALID_POINT;
  }
  double x1 = seg1[0], y1 = seg1[1], x2 = seg1[2], y2 = seg1[3];
  double x3 = seg2[0], y3 = seg2[1], x4 = seg2[2], y4 = seg2[3];
  double d = (x1 - x2) * (y3 - y4) - (x3 - x4) * (y1 - y2);
  double x =
      ((x1 * y2 - y1 * x2) * (x3 - x4) - (x3 * y4 - y3 * x4) * (x1 - x2)) / d;
  double y =
      ((x1 * y2 - y1 * x2) * (y3 - y4) - (x3 * y4 - y3 * x4) * (y1 - y2)) / d;
  if (x >= x2 + 1 || x <= x1 - 1) return INVALID_POINT;
  if (y >= max(y2, y1) + 1 || y <= min(y1, y2) - 1) return INVALID_POINT;
  ll ix = std::round(x);
  ll iy = std::round(y);
  if (x > seg1[2] || x < seg1[0]) return INVALID_POINT;
  if ((y - seg1[3]) * (y - seg1[1]) > 0) return INVALID_POINT;
  if ((seg1[3] - seg1[1]) * (ix - seg1[0]) !=
      (iy - seg1[1]) * (seg1[2] - seg1[0]))
    return INVALID_POINT;
  if (x > seg2[2] || x < seg2[0]) return INVALID_POINT;
  if ((y - seg2[3]) * (y - seg2[1]) > 0) return INVALID_POINT;
  if ((seg2[3] - seg2[1]) * (ix - seg2[0]) !=
      (iy - seg2[1]) * (seg2[2] - seg2[0]))
    return INVALID_POINT;
  return {ix, iy};
}
void Solve() {
  int n;
  cin >> n;
  vvl ps(n, vl(4));
  for (int i = 0; i < n; i++) {
    cin >> ps[i][0] >> ps[i][1] >> ps[i][2] >> ps[i][3];
    if (ps[i][0] > ps[i][2]) {
      swap(ps[i][0], ps[i][2]);
      swap(ps[i][1], ps[i][3]);
    }
  }
  ll ans = 0;
  for (auto& p : ps) ans += cnt_iterpoint(p);
  map<pii, ll> cnt_it;
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++) {
      auto itp = seg_iter(ps[i], ps[j]);
      if (itp != INVALID_POINT) {
        cnt_it[itp]++;
      }
    }
  for (auto& it : cnt_it) {
    ll k = (ll)sqrt((double)(it.second * 2));
    ans -= k;
  }
  cout << ans << endl;
}
