#include <bits/stdc++.h>
using namespace std;
const int maxn = 100100;
struct seg {
  int x, l, r;
  bool operator<(const seg& a) const {
    if (x == a.x) return l < a.l || (l == a.l && r < a.r);
    return x < a.x;
  }
} X[maxn * 60], Y[maxn * 60];
int tx, ty, d[maxn * 120], cnt[maxn * 120], td;
int main(void) {
  auto add = [](int x, int y, int xx, int yy) {
    auto P = [](int t) {
      int i = 0;
      for (; i <= 30; i++)
        if ((t >> i) & 1) break;
      return i;
    };
    if (x == xx && y == yy) {
      if (P(x) >= P(y))
        X[tx++] = (seg){x, y, y};
      else
        Y[ty++] = (seg){y, x, x};
      return;
    }
    seg _X[60], _Y[60], _XX[60], _YY[60];
    int _tx = 0, _ty = 0, _txx = 0, _tyy = 0;
    int i = 0, j = 0, px = x, py = y, pxx = xx, pyy = yy;
    for (; i <= 30 || j <= 30;) {
      if (x + y >= xx + yy) {
        for (; i <= 30 && ((x >> i) & 1) == 0 && ((y >> i) & 1) == 0; i++)
          ;
        if (i <= 30) {
          px = x, py = y;
          x &= ~(1 << i);
          y &= ~(1 << i);
        } else
          px = x, py = y, x = y = 0;
        if (x < px)
          _Y[_ty++] = (seg){y, x + 1, px};
        else if (y < py)
          _X[_tx++] = (seg){x, y + 1, py};
        else
          assert(0);
      } else {
        for (; j <= 30 && ((xx >> j) & 1) == 0 && ((yy >> j) & 1) == 0; j++)
          ;
        if (j <= 30) {
          pxx = xx, pyy = yy;
          xx &= ~(1 << j);
          yy &= ~(1 << j);
        } else
          pxx = xx, pyy = yy, xx = yy = 0;
        if (xx < pxx)
          _YY[_tyy++] = (seg){yy, xx + 1, pxx};
        else if (yy < pyy)
          _XX[_txx++] = (seg){xx, yy + 1, pyy};
        else
          assert(0);
      }
      if (x == xx && yy < y && y <= pyy) {
        _XX[_txx - 1] = (seg){x, y, pyy};
        break;
      }
      if (y == yy && xx < x && x <= pxx) {
        _YY[_tyy - 1] = (seg){y, x, pxx};
        break;
      }
      if (x == xx && y < yy && yy <= py) {
        _X[_tx - 1] = (seg){x, yy, py};
        break;
      }
      if (y == yy && x < xx && xx <= px) {
        _Y[_ty - 1] = (seg){y, xx, px};
        break;
      }
      if (x == xx && y == yy) {
        if (P(x) >= P(y))
          _X[_tx++] = (seg){x, y, y};
        else
          _Y[_ty++] = (seg){y, x, x};
        break;
      }
    }
    for (int i = 0; i < _tx; i++) X[tx++] = _X[i];
    for (int i = 0; i < _txx; i++) X[tx++] = _XX[i];
    for (int i = 0; i < _ty; i++) Y[ty++] = _Y[i];
    for (int i = 0; i < _tyy; i++) Y[ty++] = _YY[i];
  };
  int m;
  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    int x, y, xx, yy;
    scanf("%d%d%d%d", &x, &y, &xx, &yy);
    add(x, y, xx, yy);
  }
  sort(X, X + tx);
  sort(Y, Y + ty);
  auto U = [](seg X[], int& tx) {
    int t = 0;
    for (int i = 0; i < tx; i++) {
      if (i == 0 || X[i].x != X[t - 1].x || X[t - 1].r < X[i].l)
        X[t++] = X[i];
      else
        X[t - 1].r = max(X[t - 1].r, X[i].r);
    }
    tx = t;
  };
  U(X, tx);
  U(Y, ty);
  auto addD = [](seg X[], int tx) {
    for (int i = 0; i < tx; i++) {
      d[td++] = X[i].x + X[i].l;
      d[td++] = X[i].x + X[i].r + 1;
    }
  };
  d[td++] = 0;
  addD(X, tx);
  addD(Y, ty);
  sort(d, d + td);
  int t = 0;
  for (int i = 0; i < td; i++) {
    if (i == 0 || d[i] != d[t - 1])
      d[t] = d[i], cnt[t++] = 1;
    else
      cnt[t - 1]++;
  }
  td = t;
  cnt[0]--;
  for (int i = 1; i < td; i++) cnt[i] = (cnt[i] + cnt[i - 1]) % 2;
  int pre = 0, ans = 0;
  for (int i = td - 1; i >= 0; i--) {
    if (cnt[i] % 2 == pre) continue;
    pre = !pre, ans++;
  }
  printf("%d\n", ans);
  return 0;
}
