#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, yls[N << 1], ycnt, evcnt, ina[N], px[N], py[N], pu[N], pv[N];
struct Ev {
  int id, x, d, u;
} ev[N << 1];
inline bool EvCmp(const Ev &u, const Ev &v) { return u.x < v.x; }
namespace Seg {
const int S = N * 16;
int mx[S], mn[S];
set<int> st[S];
inline void PushUp(int v) {
  mn[v] = min(mn[v << 1], mn[v << 1 | 1]);
  mx[v] = max(mx[v << 1], mx[v << 1 | 1]);
  if (!st[v].empty()) {
    int bfg = *--st[v].end();
    mn[v] = max(mn[v], bfg);
    if (bfg > mx[v]) mx[v] = (ina[bfg] || bfg < mn[v]) ? 0 : bfg;
  }
}
inline void Insert(int id, int x, int y, int v = 1, int l = 1,
                   int r = ycnt - 1) {
  if (x <= l && r <= y) {
    if (id > 0)
      st[v].insert(id);
    else if (id < 0)
      st[v].erase(-id);
    PushUp(v);
    return;
  }
  int mid = (l + r) >> 1;
  if (x <= mid) Insert(id, x, y, v << 1, l, mid);
  if (y > mid) Insert(id, x, y, v << 1 | 1, mid + 1, r);
  PushUp(v);
}
}  // namespace Seg
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d%d%d", px + i, py + i, pu + i, pv + i);
    yls[++ycnt] = py[i];
    yls[++ycnt] = pv[i];
  }
  sort(yls + 1, yls + ycnt + 1);
  ycnt = unique(yls + 1, yls + ycnt + 1) - yls;
  for (int i = 1; i <= n; ++i) {
    py[i] = lower_bound(yls + 1, yls + ycnt, py[i]) - yls;
    pv[i] = lower_bound(yls + 1, yls + ycnt, pv[i]) - yls;
    ev[++evcnt] = (Ev){i, px[i], py[i], pv[i]};
    ev[++evcnt] = (Ev){-i, pu[i], py[i], pv[i]};
  }
  sort(ev + 1, ev + evcnt + 1, EvCmp);
  ev[evcnt + 1].x = ev[evcnt].x + 1;
  for (int i = 1; i <= evcnt; ++i) {
    Seg::Insert(ev[i].id, ev[i].d, ev[i].u - 1);
    if (ev[i].x != ev[i + 1].x) {
      while (Seg::mx[1] != 0) {
        int no = Seg::mx[1];
        ina[no] = 1;
        Seg::Insert(0, py[no], pv[no] - 1);
      }
    }
  }
  printf("%d\n", 1 + (int)count(ina + 1, ina + n + 1, 1));
  return 0;
}
