#include <bits/stdc++.h>
using namespace std;
int dist(int x1, int y1, int x2, int y2)
{
int dx = x2 - x1;
int dy = y2 - y1;
int res = round(sqrt(dx * dx + dy * dy));
return res;
}
int main()
{
int n;
cin >> n;
int ans = 0;
for (int i = 0; i < n; i++)
{
int x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
ans += dist(x1, y1, x2, y2);
}
cout << ans << "\n";
return 0;
}