#include <bits/stdc++.h>
using namespace std;
const int N = 1000005;
int n, d, ans;
struct ky {
  int x, y, u, v;
} a[N];
inline void gcd(const int a, const int b) {
  return !b ? d = a, void() : gcd(b, a % b);
}
inline int A(const int x) { return x < 0 ? -x : x; }
map<pair<double, double>, int> mp;
template <class I>
inline I Max(I p, I q) {
  return p > q ? p : q;
}
template <class I>
inline I Min(I p, I q) {
  return p < q ? p : q;
}
int main() {
  scanf("%d", &n);
  register int i, j;
  for (i = 1; i <= n; ++i)
    scanf("%d%d%d%d", &a[i].x, &a[i].y, &a[i].u, &a[i].v);
  for (i = 1; i <= n; ++i)
    gcd(A(a[i].v - a[i].y), A(a[i].u - a[i].x)), ans += d + 1;
  for (i = 1; i <= n; ++i)
    for (j = 2; j <= n; ++j) {
      const long long x1 = a[i].x, y1 = a[i].y, x2 = a[i].u, y2 = a[i].v,
                      x3 = a[j].x, y3 = a[j].y, x4 = a[j].u, y4 = a[j].v;
      const double x = ((double)((x1 * y2 - y1 * x2) * (x3 - x4) -
                                 (x1 - x2) * (x3 * y4 - y3 * x4))) /
                       ((double)((x1 - x2) * (y3 - y4) -
                                 (y1 - y2) * (x3 - x4))),
                   y = ((double)((x1 * y2 - y1 * x2) * (y3 - y4) -
                                 (y1 - y2) * (x3 * y4 - y3 * x4))) /
                       ((double)((x1 - x2) * (y3 - y4) -
                                 (y1 - y2) * (x3 - x4)));
      if (x != round(x) || y != round(y) || x < Min(x1, x2) ||
          x > Max(x1, x2) || x < Min(x3, x4) || x > Max(x3, x4) ||
          y < Min(y1, y2) || y > Max(y1, y2) || y < Min(y3, y4) ||
          y > Max(y3, y4))
        continue;
      if (!mp.count(make_pair(x, y)))
        mp[make_pair(x, y)] = i, --ans;
      else
        ans -= (mp[make_pair(x, y)] == i);
    }
  printf("%d", ans);
  return 0;
}
