#include<bits/stdc++.h>
using namespace std;
map<pair<int,int>,int> mp;
signed main() {
int n;
cin>>n;
double x1,x2,y1,y2;
for(int i=1; i<=n; i++) {
cin>>x1>>y1>>x2>>y2;
double k;
if(x2<x1){
swap(y1,y2);
swap(x1,x2);
}
if(x1!=x2) k=(y2-y1)/(x2-x1);
else{
if(y2<y1) swap(y1,y2);
for(int y=y1;y<=y2;y++){
mp[{x1,y}]++;
}
continue;
}
double b=y1-k*x1;
int x;
double y;
if(k>=0) {
for(x=x1; x<=x2; x++) {
y=k*x+b;
if(fabs(y - int(y)) <1e-9) mp[{x,y}]++;
}
}
else if(k<0){
for(x=x1;x<=x2;x++){
y=k*x+b;
if(fabs(y - int(y)) <1e-9) mp[{x,y}]++;
}
}
}
int ans=0;
for(auto x:mp) {
if(x.second>1) {
ans++;
}
}
cout<<ans<<endl;
return 0;
}