#include <bits/stdc++.h>
using namespace std;
const int MAX_N = (int)2e5 + 100;
vector<int> vx;
vector<pair<int, pair<int, int> > > rowOp, colOp;
map<int, vector<pair<int, int> > > row, col;
inline void normalize(int& x, const vector<int>& v) {
  x = lower_bound(v.begin(), v.end(), x) - v.begin();
}
inline void read(int n) {
  for (int i = 0; i < n; ++i) {
    int x1, y1, x2, y2;
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    if (x1 == x2) {
      if (y1 > y2) swap(y1, y2);
      row[x1].push_back(make_pair(y1, y2));
    } else {
      assert(y1 == y2);
      if (x1 > x2) swap(x1, x2);
      col[y1].push_back(make_pair(x1, x2));
    }
    vx.push_back(x1);
    vx.push_back(x2);
  }
  sort(vx.begin(), vx.end());
  vx.resize(unique(vx.begin(), vx.end()) - vx.begin());
}
long long covered = 0;
void makeDisjoint(vector<pair<int, int> >& v) {
  sort(v.begin(), v.end());
  vector<pair<int, int> > ret;
  for (auto p : v) {
    if (ret.empty()) {
      ret.push_back(p);
      continue;
    }
    if (ret.back().second >= p.first) {
      ret.back().second = max(ret.back().second, p.second);
    } else {
      ret.push_back(p);
    }
  }
  v = ret;
}
inline void process() {
  for (auto& p : row) {
    auto& v = p.second;
    makeDisjoint(v);
    for (int i = 0; i < v.size(); ++i) {
      covered += v[i].second - v[i].first + 1;
      rowOp.push_back(make_pair(p.first, v[i]));
    }
  }
  for (int i = 0; i < rowOp.size(); ++i) {
    normalize(rowOp[i].first, vx);
  }
  for (auto& p : col) {
    auto& v = p.second;
    makeDisjoint(v);
    for (int i = 0; i < v.size(); ++i) {
      covered += v[i].second - v[i].first + 1;
      colOp.push_back(make_pair(p.first, v[i]));
    }
  }
  for (int i = 0; i < colOp.size(); ++i) {
    normalize(colOp[i].second.first, vx);
    normalize(colOp[i].second.second, vx);
  }
}
const int ROW_START = 0;
const int COL = 1;
const int ROW_END = 2;
struct Event {
  int x, y1, y2;
  int type;
  Event(int x, int type, int y1, int y2 = -1)
      : x(x), type(type), y1(y1), y2(y2) {}
  bool operator<(const Event& o) const {
    if (x != o.x) return x < o.x;
    return type < o.type;
  }
};
struct BIT {
  int f[MAX_N];
  BIT() { memset(f, 0, sizeof(f)); }
  inline void add(int x, int v) {
    for (x = x + 1; x < MAX_N; x += x & -x) f[x] += v;
  }
  inline int get(int x) {
    int ret = 0;
    for (x = x + 1; x > 0; x -= x & -x) ret += f[x];
    return ret;
  }
  inline int get(int l, int r) { return get(r) - get(l - 1); }
};
int main() {
  int n;
  scanf("%d", &n);
  read(n);
  process();
  vector<Event> events;
  for (int i = 0; i < rowOp.size(); ++i) {
    events.push_back(Event(rowOp[i].second.first, ROW_START, rowOp[i].first));
    events.push_back(Event(rowOp[i].second.second, ROW_END, rowOp[i].first));
  }
  for (int i = 0; i < colOp.size(); ++i) {
    events.push_back(Event(colOp[i].first, COL, colOp[i].second.first,
                           colOp[i].second.second));
  }
  sort(events.begin(), events.end());
  BIT cnt;
  for (int i = 0; i < events.size(); ++i) {
    if (events[i].type == ROW_START) {
      cnt.add(events[i].y1, +1);
    } else if (events[i].type == ROW_END) {
      cnt.add(events[i].y1, -1);
    } else {
      covered -= cnt.get(events[i].y1, events[i].y2);
    }
  }
  cout << covered << "\n";
  return 0;
}
