#include <bits/stdc++.h>
std::mt19937 rng(
    (int)std::chrono::steady_clock::now().time_since_epoch().count());
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
struct PT {
  long long x, y;
  PT(long long xx = 0, long long yy = 0) : x(xx), y(yy) {}
  PT operator+(const PT &p) const { return PT(x + p.x, y + p.y); }
  PT operator-(const PT &p) const { return PT(x - p.x, y - p.y); }
  PT operator*(long long c) const { return PT(x * c, y * c); }
  long long operator*(const PT &p) const { return x * p.x + y * p.y; }
  long long operator%(const PT &p) const { return x * p.y - y * p.x; }
  bool operator<(const PT &p) const { return x == p.x ? y < p.y : x < p.x; }
  long long simplify() {
    long long g = gcd(std::max(x, -x), std::max(y, -y));
    x /= g;
    y /= g;
    return g;
  }
  void read() { std::cin >> x >> y; }
};
struct Segment {
  PT p1, p2;
  long long a, b, c;
  Segment() {}
  Segment(PT st, PT en) {
    p1 = st, p2 = en;
    a = -(st.y - en.y);
    b = st.x - en.x;
    c = -(a * en.x + b * en.y);
  }
  bool inSegment(PT p) {
    if ((p1 - p) % (p1 - p2) != 0) {
      return false;
    }
    return (p1 - p2) * (p - p2) >= 0 && (p2 - p1) * (p - p1) >= 0;
  }
  PT lineIntersection(Segment s) {
    long double x = (long double)s.c * b - (long double)c * s.b;
    long double y = (long double)s.a * c - (long double)a * s.c;
    long double tmp = (long double)a * s.b - (long double)s.a * b;
    x /= tmp;
    y /= tmp;
    return PT(round(x), round(y));
  }
  void read() {
    p1.read();
    p2.read();
    *this = Segment(p1, p2);
  }
  long long points() { return (p2 - p1).simplify() + 1; }
};
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(NULL);
  int n;
  std::cin >> n;
  std::vector<Segment> segs;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    Segment curSeg;
    curSeg.read();
    ans += curSeg.points();
    std::set<PT> st;
    for (int j = 0; j < i; j++) {
      PT cand = curSeg.lineIntersection(segs[j]);
      if (curSeg.inSegment(cand) && segs[j].inSegment(cand)) {
        st.insert(cand);
      }
    }
    ans -= st.size();
    segs.push_back(curSeg);
  }
  std::cout << ans << std::endl;
}
