#include <bits/stdc++.h>
using namespace std;
long long quickpow(long long a, long long b, long long MOD) {
  long long ans = 1;
  a %= MOD;
  while (b) {
    if (b & 1ll) ans = ans * a % MOD;
    a = a * a % MOD, b >>= 1;
  }
  return ans;
}
long long gcd(long long a, long long b) {
  return a % b == 0 ? b : gcd(b, a % b);
}
const int MAXN = 2010;
const double eps = 1e-10;
double add(double a, double b) {
  if (abs(a + b) < eps * (abs(a) + abs(b))) return 0;
  return a + b;
}
struct Point {
  double x, y;
  Point(){};
  Point(double x, double y) : x(x), y(y){};
  Point operator+(Point p) { return Point(add(x, p.x), add(y, p.y)); }
  Point operator-(Point p) { return Point(add(x, -p.x), add(y, -p.y)); }
  Point operator*(double d) { return Point(d * x, d * y); }
  double dot(Point p) { return add(x * p.x, y * p.y); }
  double det(Point p) { return add(x * p.y, -y * p.x); }
  bool operator<(const Point &ppp) const {
    if (x != ppp.x)
      return x < ppp.x;
    else
      return y < ppp.y;
  }
} p[MAXN];
set<Point> dict;
bool on_seg(Point p1, Point p2, Point q) {
  return abs((p1 - q).det(p2 - q)) == 0 && (p1 - q).dot(p2 - q) <= 0;
}
Point intersection(Point p1, Point p2, Point q1, Point q2) {
  return p1 + (p2 - p1) * ((q2 - q1).det(q1 - p1) / (q2 - q1).det(p2 - p1));
}
int main() {
  int n;
  while (~scanf("%d", &n)) {
    long long ans = 0;
    for (int i = 0; i < n; i++) {
      scanf("%lf%lf%lf%lf", &p[i * 2].x, &p[i * 2].y, &p[i * 2 + 1].x,
            &p[i * 2 + 1].y);
      if (p[i * 2 + 1].x == p[i * 2].x)
        ans += abs(p[i * 2 + 1].y - p[i * 2].y) + 1;
      else if (p[i * 2 + 1].y == p[i * 2].y)
        ans += abs(p[i * 2 + 1].x - p[i * 2].x) + 1;
      else
        ans += (gcd((long long)(abs(p[i * 2 + 1].x - p[i * 2].x)),
                    (long long)(abs(p[i * 2 + 1].y - p[i * 2].y))) +
                1);
    }
    for (int i = 0; i < n; i++) {
      dict.clear();
      for (int j = i + 1; j < n; j++) {
        Point temp =
            intersection(p[i * 2], p[i * 2 + 1], p[j * 2], p[j * 2 + 1]);
        if (!on_seg(p[i * 2], p[i * 2 + 1], temp) ||
            !on_seg(p[j * 2], p[j * 2 + 1], temp))
          continue;
        if (fabs(temp.x - round(temp.x)) < eps &&
            fabs(temp.y - round(temp.y)) < eps) {
          temp.x = round(temp.x), temp.y = round(temp.y);
          if (dict.find(temp) == dict.end()) {
            dict.insert(temp);
          }
        }
      }
      ans -= dict.size();
    }
    printf("%I64d\n", ans);
  }
  return 0;
}
