#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <queue>
#include <cmath>
#include <algorithm>
using namespace std;
#define MAXN 1610

#define INF 1000000007
const double EPS = 1e-10;
inline int dcmp(double x)
{
    if(fabs(x)<EPS) return 0;
    return x<0?-1:1;
}
struct Point{
    double x,y;
    Point(){}
    Point(double a,double b):x(a),y(b){}
    Point operator +(const Point &a)const{return Point(x+a.x,y+a.y);}
    Point operator -(const Point &a)const{return Point(x-a.x,y-a.y);}
    Point operator*(double k)const{return Point(x*k,y*k);}
    bool operator <(const Point &a)const
    {
        return dcmp(x-a.x)<0||(dcmp(x-a.x)==0&&dcmp(y-a.y)<0);
    }
    void input(){scanf("%lf%lf",&x,&y);}
}a[MAXN],b[MAXN];
typedef Point Vector;
inline double cross(Vector a,Vector b)
{
    return a.x*b.y+a.y*b.x;
}
inline double dot(Vector a,Vector b)
{
    return a.x*b.x+a.y*b.y;
}
inline double length(Vector a)
{
    return sqrt(dot(a,a));
}
bool getinter(Point a,Vector aa,Point b,Vector bb)
{
    Vector u = a-b;
    double t = cross(bb,u)/cross(aa,bb);
    Point r = a+aa*t;
    int xx = (int)r.x,yy = (int)r.y;
    return dcmp(a.x-xx)==0&&dcmp(a.y-yy)==0;
}
int judge(Point s1,Point e1,Point s2,Point e2)
{
    if(dcmp(dot(s1-e1,s2-e2))==0)
    {
        if(dcmp(dot(s1-s2,e1-e2))==0) return 2;
        else return 0;
    }
    if(min(s1.x,e1.x)<=max(s2.x,e2.x)&&
       min(s1.y,e1.y)<=max(s1.y,e2.y)&&
       min(s2.x,e2.x)<=max(s1.x,e1.x)&&
       min(s2.y,e2.y)<=max(s1.y,e1.y)&&
       dcmp(cross(s2-s1,e2-s1))*dcmp(cross(s2-e1,e2-e1))<=0&&
       dcmp(cross(s1-s2,e1-s2)*dcmp(cross(s1-e2,e1-e2)))<=0)
        return 1;
    return 0;
}
int main()
{
    freopen("/home/moor/Code/input","r",stdin);
    int n;
    int ans;
    while(scanf("%d",&n)!=EOF)
    {
        ans = 0;
        for(int i  = 0; i<n; i++)
        {
            a[i].input();
            b[i].input();
            if(dcmp(a[i].x-b[i].x)&&dcmp(a[i].y-b[i].y))
                ans+=__gcd((int)abs(a[i].x-b[i].x),(int)abs(a[i].y-b[i].y))+1;
            else ans+=abs(a[i].x-b[i].x)+abs(a[i].y-b[i].y)+1;
        }
        for(int i = 0; i < n; i++)
        {
            for(int j = i+1; j<n; j++)
            {
                int tmp = judge(a[i],b[i],a[j],b[j]);
                if(tmp == 1) ans-=getinter(a[i],b[i]-a[i],a[j],b[j]-a[j]);
                else if(tmp==2)
                {
                    if(b[i]<a[i]) swap(a[i],b[i]);
                    if(b[j]<a[j]) swap(a[j],b[j]);
                    Point aa = max(a[i],a[j]), bb = min(b[i],b[j]);
                     if(dcmp(aa.x-bb.x)&&dcmp(aa.y-bb.y))
                        ans-=__gcd((int)fabs(aa.x-bb.x),(int)fabs(aa.y-bb.y))+1;
                    else ans-=abs(aa.x-bb.x)+abs(aa.y-bb.y)+1;
                }
            }
        }
        printf("%d\n",ans);
    }
}