#include <bits/stdc++.h>
using namespace std;
const int N = 1e5;
const int INF = 1e9;
int n;
int lx[N], ly[N], rx[N], ry[N];
map<int, int> fw, val, last;
int get(int r) {
  int v = 0;
  for (r += INF; r >= 0; r &= r + 1, --r) {
    if (fw.count(r)) {
      v += fw[r];
    }
  }
  return v;
}
void upd(int r, int v) {
  for (r += INF; r <= 2 * INF; r |= r + 1) {
    if ((fw[r] += v) == 0) {
      fw.erase(r);
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin >> n;
  vector<array<int, 3>> eve;
  long long res = 0LL;
  for (int i = 0; i < n; ++i) {
    cin >> lx[i] >> ly[i] >> rx[i] >> ry[i];
    if (lx[i] > rx[i]) swap(lx[i], rx[i]);
    if (ly[i] > ry[i]) swap(ly[i], ry[i]);
    if (lx[i] != rx[i]) {
      eve.push_back({lx[i], -1, i});
      eve.push_back({rx[i], 1, i});
    } else {
      eve.push_back({lx[i], 0, i});
    }
  }
  sort(eve.begin(), eve.end());
  for (int i = 0, j; i < int(eve.size()); i = j) {
    int id = eve[i][2];
    if (eve[i][1] == -1) {
      if (++val[ly[id]] == 1) {
        upd(ly[id], 1);
        last[ly[id]] = eve[i][0];
      }
      j = i + 1;
    } else if (eve[i][1] == 0) {
      for (j = i; j < int(eve.size()) and eve[j][0] == eve[i][0] and
                  eve[j][1] == eve[i][1];
           ++j)
        ;
      vector<array<int, 2>> seg;
      for (int k = i; k < j; ++k) {
        id = eve[k][2];
        seg.push_back({ly[id], -1});
        seg.push_back({ry[id], 1});
      }
      sort(seg.begin(), seg.end());
      for (int k = 0, bal = 0, lst = -INF; k < int(seg.size()); ++k) {
        if (seg[k][1] == -1) {
          if (++bal == 1) {
            lst = seg[k][0];
          }
        } else {
          if (--bal == 0) {
            res += seg[k][0] - lst + 1;
            res -= get(seg[k][0]) - get(lst - 1);
          }
        }
      }
    } else {
      if (--val[ly[id]] == 0) {
        upd(ly[id], -1);
        res += eve[i][0] - last[ly[id]] + 1;
      }
      j = i + 1;
    }
  }
  cout << res << '\n';
  return 0;
}
