#include <bits/stdc++.h>
using namespace std;
const int inf = 1000000010;
struct struktura {
  int y, tip, x1, x2;
  struktura() {}
  struktura(int _y, int _tip, int _x1, int _x2 = 0) {
    y = _y;
    tip = _tip;
    x1 = _x1;
    x2 = _x2;
  }
};
int cmp(struktura a, struktura b) {
  if (a.y != b.y) return a.y < b.y;
  if (a.tip != b.tip) return a.tip < b.tip;
  if (a.x1 != b.x1) return a.x1 < b.x1;
  return a.x2 < b.x2;
}
int n;
long long int rj;
map<int, vector<pair<int, int> > > vodoravni, okomiti;
map<int, vector<pair<int, int> > >::iterator it;
vector<struktura> event;
map<int, int> FWT;
void sredi() {
  for (it = vodoravni.begin(); it != vodoravni.end(); it++) {
    vector<pair<int, int> > v = it->second;
    sort(v.begin(), v.end());
    pair<int, int> sad(-1, -1);
    int num = 0;
    for (int i = 0; i < v.size(); i++) {
      if (sad.first == -1) sad.first = v[i].first;
      num += v[i].second;
      if ((i == v.size() - 1 ||
           i < v.size() - 1 && v[i + 1].first != v[i].first) &&
          num == 0) {
        sad.second = v[i].first;
        event.push_back(struktura(it->first, 0, sad.first, sad.second));
        rj += sad.second - sad.first + 1;
        sad = pair<int, int>(-1, -1);
      }
    }
  }
  for (it = okomiti.begin(); it != okomiti.end(); it++) {
    vector<pair<int, int> > v = it->second;
    sort(v.begin(), v.end());
    pair<int, int> sad(-1, -1);
    int num = 0;
    for (int i = 0; i < v.size(); i++) {
      if (sad.first == -1) sad.first = v[i].first;
      num += v[i].second;
      if ((i == v.size() - 1 ||
           i < v.size() - 1 && v[i + 1].first != v[i].first) &&
          num == 0) {
        sad.second = v[i].first;
        event.push_back(struktura(sad.first, -1, it->first));
        event.push_back(struktura(sad.second, 1, it->first));
        rj += sad.second - sad.first + 1;
        sad = pair<int, int>(-1, -1);
      }
    }
  }
}
void ubaci(long long int x, int v) {
  for (; x < 2ll * inf; x += x & -x) FWT[x] += v;
}
int upit(int x) {
  int ret = 0;
  for (; x > 0; x -= x & -x) ret += FWT[x];
  return ret;
}
int query(int a, int b) { return upit(b) - upit(a - 1); }
void rijesi() {
  sort(event.begin(), event.end(), cmp);
  for (int i = 0; i < event.size(); i++) {
    struktura sad = event[i];
    if (sad.tip == -1) ubaci(sad.x1, 1);
    if (sad.tip == 1) ubaci(sad.x1, -1);
    if (sad.tip == 0) rj -= query(sad.x1, sad.x2);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int x1, y1, x2, y2;
    scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
    x1 += inf;
    y1 += inf;
    x2 += inf;
    y2 += inf;
    if (y1 == y2) {
      if (x1 > x2) swap(x1, x2);
      vodoravni[y1].push_back(pair<int, int>(x1, 1));
      vodoravni[y1].push_back(pair<int, int>(x2, -1));
    } else {
      if (y1 > y2) swap(y1, y2);
      okomiti[x1].push_back(pair<int, int>(y1, 1));
      okomiti[x1].push_back(pair<int, int>(y2, -1));
    }
  }
  sredi();
  rijesi();
  cout << rj << endl;
  return 0;
}
