#include <bits/stdc++.h>
using namespace std;
const int maxn = 1005;
pair<long long, long long> operator+(pair<long long, long long> b,
                                     pair<long long, long long> c) {
  return pair<long long, long long>(b.first + c.first, b.second + c.second);
}
pair<long long, long long> operator-(pair<long long, long long> b,
                                     pair<long long, long long> c) {
  return pair<long long, long long>(b.first - c.first, b.second - c.second);
}
pair<long long, long long> operator*(pair<long long, long long> b,
                                     long long v) {
  return pair<long long, long long>(b.first * v, b.second * v);
}
pair<long long, long long> operator/(pair<long long, long long> b,
                                     long long v) {
  return pair<long long, long long>(b.first / v, b.second / v);
}
int n, tot;
pair<pair<long long, long long>, pair<long long, long long> > seg[maxn];
pair<long long, long long> p[maxn * maxn];
int cnt[maxn];
void read() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i)
    scanf("%lld%lld%lld%lld", &seg[i].first.first, &seg[i].first.second,
          &seg[i].second.first, &seg[i].second.second);
}
long long det(pair<long long, long long> b, pair<long long, long long> c,
              pair<long long, long long> o) {
  return (b.first - o.first) * (c.second - o.second) -
         (b.second - o.second) * (c.first - o.first);
}
int sgn(long long first) {
  if (first > 0) return 1;
  if (first == 0) return 0;
  return -1;
}
long long gcd(long long first, long long second) {
  return (second == 0 ? first : gcd(second, first % second));
}
long long gcd(pair<long long, long long> b) {
  return (b.second == 0 ? b.first : gcd(b.second, b.first % b.second));
}
bool cross(pair<pair<long long, long long>, pair<long long, long long> > b,
           pair<pair<long long, long long>, pair<long long, long long> > c,
           int s, pair<long long, long long> &ret) {
  if (sgn(det(b.second, c.first, b.first)) *
              sgn(det(b.second, c.second, b.first)) >
          0 ||
      sgn(det(c.second, b.first, c.first)) *
              sgn(det(c.second, b.second, c.first)) >
          0)
    return false;
  long long rate1 = abs(det(c.first, c.second, b.first));
  long long rate2 = abs(det(c.first, c.second, b.second));
  rate2 += rate1;
  long long d = gcd(rate1, rate2);
  rate1 /= d;
  rate2 /= d;
  if (s % rate2 != 0) return false;
  pair<long long, long long> tmp = b.second - b.first;
  tmp = tmp / s * (rate1 * (s / rate2));
  ret = tmp + b.first;
  return true;
}
void solve() {
  long long ans = 0;
  for (int i = 1; i <= n; ++i)
    ans += 1 + (cnt[i] = abs(gcd(seg[i].first - seg[i].second)));
  tot = 0;
  for (int i = 1; i <= n; ++i)
    for (int j = i + 1; j <= n; ++j) {
      pair<long long, long long> tmp;
      if (cross(seg[i], seg[j], cnt[i], tmp)) p[++tot] = tmp;
    }
  sort(p + 1, p + 1 + tot);
  for (int i = 1; i <= tot;) {
    int j = i;
    while (j <= tot && p[i] == p[j]) ++j;
    int tmp = 1;
    while (tmp * (tmp - 1) < (j - i) * 2) ++tmp;
    ans -= tmp - 1;
    i = j;
  }
  printf("%lld\n", ans);
}
int main() {
  read();
  solve();
  return 0;
}
