#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > s;
int getid(int x, int y) {
  return lower_bound(s.begin(), s.end(), make_pair(x, y)) - s.begin();
}
void add(int x, int y) {
  while (x || y) {
    s.push_back(make_pair(x, y));
    if (y == 0 || x > 0 && ((x) & -(x)) < ((y) & -(y))) {
      s.push_back(make_pair(x - 1, y));
      x ^= ((x) & -(x));
    } else {
      s.push_back(make_pair(x, y - 1));
      y ^= ((y) & -(y));
    }
  }
}
int main() {
  int m;
  scanf("%d", &m);
  vector<int> x1(m), y1(m), x2(m), y2(m);
  s.push_back(make_pair(0, 0));
  for (int i = (0); i < (m); ++i) {
    scanf("%d%d%d%d", &x1[i], &y1[i], &x2[i], &y2[i]);
    add(x1[i], y1[i]);
    add(x2[i], y2[i]);
  }
  sort(s.begin(), s.end());
  int n = unique(s.begin(), s.end()) - s.begin();
  s.resize(n);
  vector<int> gx(n), gy(n), dep(n, 0), top(n, 0), fa(n, 0), type(n);
  for (int i = (0); i < (n); ++i) gx[i] = gy[i] = i;
  for (int i = (1); i < (n); ++i) {
    int x = s[i].first, y = s[i].second;
    dep[i] = x + y;
    type[i] = (y == 0 || x > 0 && ((x) & -(x)) < ((y) & -(y))) ^ 1;
    while ((x || y) &&
           (y == 0 || x > 0 && ((x) & -(x)) < ((y) & -(y))) != type[i]) {
      if (!type[i])
        x ^= ((x) & -(x));
      else
        y ^= ((y) & -(y));
    }
    top[i] = getid(x, y);
    if (!type[i]) {
      fa[i] = gx[top[i]];
      gx[top[i]] = i;
    } else {
      fa[i] = gy[top[i]];
      gy[top[i]] = i;
    }
  }
  auto lca = [&](int u, int v) {
    for (; top[u] != top[v]; u = top[u]) {
      if (dep[top[u]] < dep[top[v]]) swap(u, v);
    }
    if (type[u] == type[v]) {
      if (dep[u] > dep[v]) return v;
      return u;
    }
    return top[u];
  };
  vector<int> a(n, 0);
  for (int i = (0); i < (m); ++i) {
    int u = getid(x1[i], y1[i]), v = getid(x2[i], y2[i]);
    int f = lca(u, v);
    a[u]++, a[v]++;
    a[f]--;
    if (f) a[fa[f]]--;
  }
  for (int i = (n)-1; i >= (1); --i) a[fa[i]] += a[i];
  for (int i = (0); i < (n); ++i) a[i] = a[i] > 0;
  for (int i = (1); i < (n); ++i) a[fa[i]] ^= a[i];
  vector<int> vec;
  for (int i = (0); i < (n); ++i)
    if (a[i]) vec.push_back(dep[i]);
  sort(vec.begin(), vec.end());
  int ans = 0;
  for (int i = 0, j; i < vec.size(); i = j) {
    j = i;
    while (j < vec.size() && vec[i] == vec[j]) ++j;
    ans += (j - i) & 1;
  }
  printf("%d\n", ans);
}
