#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll gcd(ll a, ll b) {
  while (a > 0 && b > 0) {
    if (a >= b)
      a %= b;
    else
      b %= a;
  }
  return a + b;
}
struct point {
  ll x, y;
  point() : x(0), y(0) {}
  point(ll x, ll y) : x(x), y(y) {}
  point operator+(point p) { return point(x + p.x, y + p.y); }
  point operator-(point p) { return point(x - p.x, y - p.y); }
  ll operator*(point p) { return x * p.x + y * p.y; }
  point operator*(ll t) { return point(x * t, y * t); }
  ll operator^(point p) { return x * p.y - y * p.x; }
  bool operator<(point p) const { return (x < p.x) || (x == p.x && y < p.y); }
};
void read(point &p) {
  ll x, y;
  cin >> x >> y;
  p.x = x, p.y = y;
}
void write(point p) { cout << "(" << p.x << ", " << p.y << ") "; }
ll orientation(point p, point q, point r) {
  ll x = (p - q) ^ (r - q);
  return x > 0 ? 1 : x < 0 ? -1 : 0;
}
pair<point, bool> intersect(point p1, point p2, point q1, point q2) {
  ll orie1 = orientation(q2, q1, p1);
  ll orie2 = orientation(q2, q1, p2);
  ll orie3 = orientation(p2, p1, q1);
  ll orie4 = orientation(p2, p1, q2);
  if (orie1 * orie2 <= 0 && orie3 * orie4 <= 0) {
    point a = p1 - q1;
    point b = p2 - p1;
    point c = q2 - q1;
    ll f = gcd(abs(b.x), abs(b.y));
    b.x /= f;
    b.y /= f;
    ll num = a ^ c;
    ll denom = c ^ b;
    if (num % denom) return {point(), false};
    ll i = (num) / (denom);
    return {point(p1 + b * i), true};
  } else
    return {point(), false};
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios::fixed);
  cout.precision(11);
  int n;
  cin >> n;
  vector<pair<point, point> > seg(n);
  for (int i = 0; i < n; i++) {
    read(seg[i].first);
    read(seg[i].second);
  }
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    point p = seg[i].first - seg[i].second;
    ans += gcd(abs(p.x), abs(p.y)) + 1;
    set<point> pts;
    for (int j = i + 1; j < n; j++) {
      pair<point, bool> x =
          intersect(seg[i].first, seg[i].second, seg[j].first, seg[j].second);
      if (x.second == false) continue;
      pts.insert(x.first);
    }
    ans -= pts.size();
  }
  cout << ans << "\n";
  return 0;
}
