#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0;
  char ch = getchar();
  bool d = 1;
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') d = 0;
  for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
  return d ? x : -x;
}
inline unsigned long long rnd() {
  return ((unsigned long long)rand() << 30 ^ rand()) << 4 | rand() % 4;
}
const int N = 1e5 + 5;
int D(pair<int, int> x) { return x.first + x.second; }
pair<int, int> top(pair<int, int> x) {
  if (x.first == 0 || x.second == 0) return make_pair(0, 0);
  if ((x.first & -x.first) < (x.second & -x.second))
    return make_pair(x.first - (x.first & ((x.second & -x.second) - 1)),
                     x.second);
  return make_pair(x.first, x.second - (x.second & ((x.first & -x.first) - 1)));
}
bool check(pair<int, int> x, pair<int, int> y) {
  return top(x) == top(y) && (x.first == y.first || x.second == y.second);
}
pair<int, int> lca(pair<int, int> x, pair<int, int> y) {
  while (!check(x, y)) {
    if (D(top(x)) < D(top(y))) swap(x, y);
    x = top(x);
  }
  return D(x) < D(y) ? x : y;
}
int st[1 << 15 | 5];
bool cmp(pair<int, int> x, pair<int, int> y) {
  if (x == y) return 0;
  int v = (x.first ^ y.first) | (x.second ^ y.second);
  int i = (v >> 15 ? st[v >> 15] + 15 : st[v]);
  int c0 = (x.first >> i) & 1;
  int c1 = (x.second >> i) & 1;
  int c2 = (y.first >> i) & 1;
  int c3 = (y.second >> i) & 1;
  int t1 = (c0 ? 0 : (c1 ? 2 : 1));
  int t2 = (c2 ? 0 : (c3 ? 2 : 1));
  if (t1 == 2) return 0;
  if (t2 == 2) return 1;
  if (t1 == 1) return ((x.second & ((1 << i) - 1)) == 0) ? 1 : 0;
  if (t2 == 1) return ((y.second & ((1 << i) - 1)) == 0) ? 0 : 1;
}
vector<long long> v[N << 2];
int sum[N << 2], a[N << 3], m, dep[N << 2], S[N << 2];
bool used[N << 2];
pair<int, int> q[N << 2], x[N], y[N];
void dfs(int u, int fa) {
  dep[u] = D(q[u]);
  for (auto k : v[u]) dfs(k, u), sum[u] += sum[k];
  if (sum[u])
    a[++m] = dep[u] + 1, a[++m] = dep[fa] + 1;
  else if (used[u])
    a[++m] = dep[u], a[++m] = dep[u] + 1;
}
map<pair<int, int>, int> id;
int main() {
  for (int i = (int)(0); i <= (int)(32767); i++)
    for (int j = (int)(0); j <= (int)(14); j++) {
      if (i & (1 << j)) st[i] = j;
    }
  int n = read(), k = 0;
  for (int i = (int)(1); i <= (int)(n); i++) {
    x[i].first = read();
    x[i].second = read();
    y[i].first = read();
    y[i].second = read();
    q[++k] = x[i];
    q[++k] = y[i];
  }
  sort(q + 1, q + k + 1);
  k = unique(q + 1, q + k + 1) - q;
  sort(q + 1, q + k + 1, cmp);
  for (int i = (int)(1); i <= (int)(k - 1); i++) q[k + i] = lca(q[i], q[i + 1]);
  k = k * 2 - 1;
  sort(q + 1, q + k + 1, cmp);
  k = unique(q + 1, q + k + 1) - q - 1;
  int top = 1;
  S[top] = 1;
  for (int i = (int)(2); i <= (int)(k); i++) {
    while (top && lca(q[S[top]], q[i]) != q[S[top]]) top--;
    v[S[top]].push_back(i);
    S[++top] = i;
  }
  for (int i = (int)(1); i <= (int)(k); i++) id[q[i]] = i;
  for (int i = (int)(1); i <= (int)(n); i++) {
    int id1 = id[x[i]], id2 = id[y[i]];
    int id3 = id[lca(x[i], y[i])];
    sum[id1]++;
    sum[id2]++;
    sum[id3] -= 2;
    used[id3] = 1;
  }
  dfs(1, 0);
  sort(a + 1, a + m + 1);
  int ans = 0, ssw = 0;
  for (int i = 1, j; i <= m; i = j) {
    j = i;
    while (j <= m && a[j] == a[i]) j++;
    if (a[i] == 0)
      ssw = (j - i) % 2;
    else
      ans += (j - i) % 2;
  }
  if (ans % 2 != ssw) ans++;
  cout << ans;
}
