#include <bits/stdc++.h>
using namespace std;
static inline void canhazfast() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
}
template <typename T>
T gcd(T a, T b) {
  return b == 0 ? a : gcd(b, a % b);
}
template <typename T>
T extgcd(T a, T b, T &x, T &y) {
  T x0 = 1, y0 = 0, x1 = 0, y1 = 1;
  while (b) {
    T q = a / b;
    a %= b;
    swap(a, b);
    x0 -= q * x1;
    swap(x0, x1);
    y0 -= q * y1;
    swap(y0, y1);
  }
  x = x0;
  y = y0;
  return a;
}
static inline int ctz(unsigned x) { return __builtin_ctz(x); }
static inline int ctzll(unsigned long long x) { return __builtin_ctzll(x); }
static inline int clz(unsigned x) { return __builtin_clz(x); }
static inline int clzll(unsigned long long x) { return __builtin_clzll(x); }
static inline int popcnt(unsigned x) { return __builtin_popcount(x); }
static inline int popcntll(unsigned long long x) {
  return __builtin_popcountll(x);
}
static inline int bsr(unsigned x) { return 31 ^ clz(x); }
static inline int bsrll(unsigned long long x) { return 63 ^ clzll(x); }
istream &operator>>(istream &is, pair<int, int> &p) {
  return is >> p.first >> p.second;
}
pair<int, int> operator+(const pair<int, int> &a, const pair<int, int> &b) {
  return make_pair(a.first + b.first, a.second + b.second);
}
pair<int, int> operator-(const pair<int, int> &a, const pair<int, int> &b) {
  return make_pair(a.first - b.first, a.second - b.second);
}
pair<int, int> operator*(int f, const pair<int, int> &p) {
  return make_pair(f * p.first, f * p.second);
}
pair<int, int> operator*(const pair<int, int> &p, int f) {
  return make_pair(f * p.first, f * p.second);
}
pair<int, int> operator/(const pair<int, int> &p, int f) {
  return make_pair(p.first / f, p.second / f);
}
long long cross(const pair<int, int> &a, const pair<int, int> &b) {
  return (long long)a.first * b.second - (long long)b.first * a.second;
}
struct L {
  pair<int, int> p0, dir;
  int tmx;
};
int main() {
  canhazfast();
  static L ln[1024];
  int n, ans = 0;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    pair<int, int> a, b;
    int c;
    cin >> a >> b;
    b = b - a;
    c = abs(gcd(b.first, b.second));
    ln[i] = {a, b / c, c};
    ans += c + 1;
  }
  for (int i = 1; i < n; ++i) {
    set<pair<int, int> > s;
    const L &a = ln[i];
    for (int j = 0; j < i; ++j) {
      const L &b = ln[j];
      long long det = cross(a.dir, b.dir);
      if (det == 0) continue;
      pair<int, int> diff = a.p0 - b.p0;
      long long numa = cross(b.dir, diff);
      long long ta = numa / det, ra = numa % det;
      if (ra || ta < 0 || ta > a.tmx) continue;
      long long numb = cross(a.dir, diff);
      long long tb = numb / det, rb = numb % det;
      if (rb || tb < 0 || tb > b.tmx) continue;
      s.insert(a.p0 + (int)ta * a.dir);
    }
    ans -= (int)s.size();
  }
  cout << ans;
  return 0;
}
