#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const long long INF_LL = 4e18;
const double pi = acos(-1.0);
template <class T>
T& smin(T& x, const T& y) {
  if (x > y) x = y;
  return x;
}
template <class T>
T& smax(T& x, const T& y) {
  if (x < y) x = y;
  return x;
}
template <class T>
T sqr(const T& x) {
  return x * x;
}
template <typename Iterator>
void print(const char* fmt, Iterator begin, Iterator end,
           const char* delimiter = " ", const char* closing = "\n") {
  for (; begin != end; ++begin != end ? printf("%s", delimiter) : 0)
    printf(fmt, *begin);
  printf("%s", closing);
}
template <class T, bool COMMUTATIVE = true>
class SegmentTree {
  int n;
  vector<T> tree;

 public:
  SegmentTree(int newn = 0) { init(newn); }
  void init(int newn) {
    n = newn;
    vector<T>(2 * n).swap(tree);
  }
  int size() const { return n; }
  T& operator[](int i) { return tree[i + n]; }
  const T& operator[](int i) const { return tree[i + n]; }
  void build() {
    for (int i = n; --i;) tree[i] = combine(tree[i << 1], tree[i << 1 | 1]);
  }
  void set(int i, const T& value) {
    for (tree[i += n] = value; i >>= 1;)
      tree[i] = combine(tree[i << 1], tree[i << 1 | 1]);
  }
  void add(int i, const T& delta) {
    assert(COMMUTATIVE);
    for (i += n; i; i >>= 1) tree[i].add(delta);
  }
  T query(int l, int r) const {
    T resl = T(), resr = T();
    for (l += n, r += n; l < r; l >>= 1, r >>= 1)
      if (COMMUTATIVE) {
        if (l & 1) resl.add(tree[l++]);
        if (r & 1) resr.add(tree[--r]);
      } else {
        if (l & 1) resl = combine(resl, tree[l++]);
        if (r & 1) resr = combine(tree[--r], resr);
      }
    return combine(resl, resr);
  }
};
template <class T>
struct Tsum {
  T value;
  Tsum(const T& value = 0) : value(value) {}
  operator T() const { return value; }
  void add(const Tsum& other) { value += other.value; }
  friend Tsum combine(const Tsum& lhs, const Tsum& rhs) {
    return lhs.value + rhs.value;
  }
};
struct S {
  bool ex;
  int a, b, c;
  void inp() {
    int x1, y1, x2, y2;
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    if (x1 == x2) {
      ex = true;
      a = y1;
      b = y2;
      c = x1;
    } else {
      ex = false;
      a = x1;
      b = x2;
      c = y1;
    }
    if (a > b) swap(a, b);
  }
};
bool ccmp(const S& a, const S& b) { return tie(a.c, a.a) < tie(b.c, b.a); }
vector<S> x, y;
map<int, int> my;
vector<pair<int, int>> e;
int main() {
  cin.tie(NULL);
  int n;
  S t;
  scanf("%d", &n);
  for (int i(0), _b(n); i < _b; ++i) {
    t.inp();
    if (t.ex) {
      x.push_back(t);
      my[t.a] = my[t.b + 1] = 0;
    } else {
      y.push_back(t);
      my[t.c] = 0;
    }
  }
  int k = 0;
  for (auto& p : my) p.second = k++;
  long long ans = 0;
  sort((x).begin(), (x).end(), ccmp);
  sort((y).begin(), (y).end(), ccmp);
  int r = 0;
  for (int i(0), _b(int((y).size())); i < _b; ++i) {
    int a = y[i].a;
    if (i == 0 || y[i - 1].c != y[i].c) r = -2 * INF;
    smax(a, r + 1);
    smax(r, y[i].b);
    if (a <= y[i].b) {
      ans += y[i].b + 1 - a;
      e.emplace_back(a, i);
      e.emplace_back(y[i].b + 1, -i - 1);
    }
  }
  sort((e).begin(), (e).end());
  SegmentTree<Tsum<int>> tree(k);
  int u = 0;
  for (int i(0), _b(int((x).size())); i < _b; ++i) {
    while (u < int((e).size()) && e[u].first <= x[i].c) {
      if (e[u].second >= 0)
        tree.add(my[y[e[u].second].c], 1);
      else
        tree.add(my[y[-e[u].second - 1].c], -1);
      ++u;
    }
    int a = x[i].a;
    if (i == 0 || x[i - 1].c != x[i].c) r = -2 * INF;
    smax(a, r + 1);
    smax(r, x[i].b);
    if (a <= x[i].b) {
      ans += x[i].b + 1 - a;
      ans -= tree.query(my[a], my[x[i].b + 1]);
    }
  }
  cout << ans << endl;
  return 0;
}
