#include <bits/stdc++.h>
const int maxn = 1e6 + 9, mod = 998244353, inf = 0x3f3f3f3f;
int Read() {
  int x(0), f(1);
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 3ll) + (x << 1ll) + c - '0';
    c = getchar();
  }
  return x * f;
}
void Chkmin(int &x, int y) {
  if (y < x) x = y;
}
void Chkmax(int &x, int y) {
  if (y > x) x = y;
}
int add(int x, int y) { return x += y, x >= mod ? x - mod : x; }
int dec(int x, int y) { return x -= y, x < 0 ? x + mod : x; }
int mul(int x, int y) { return 1ll * x * y % mod; }
int Pow(int base, int b) {
  int ret(1);
  while (b) {
    if (b & 1) ret = mul(ret, base);
    base = mul(base, base);
    b >>= 1;
  }
  return ret;
}
struct Rat {
  int x1, x2, y1, y2, id;
} a[maxn];
struct Qy {
  int l, r, id;
};
int n, ans;
int mi[maxn], mx[maxn], mark[maxn];
std::vector<Qy> Q[maxn];
std::set<int> Set[maxn];
void Update(int nw, int op) {
  if (op) {
    mi[nw] = mx[nw] = 0;
  } else {
    mi[nw] = std::min(mi[nw << 1], mi[nw << 1 | 1]);
    mx[nw] = std::max(mx[nw << 1], mx[nw << 1 | 1]);
  }
  if (Set[nw].size()) {
    int x(*Set[nw].rbegin());
    Chkmax(mi[nw], x);
    if (!mark[x]) {
      Chkmax(mx[nw], x);
    }
  }
  if (mi[nw] > mx[nw]) mx[nw] = 0;
}
void Modify(int nw, int l, int r, int lt, int rt, int id) {
  if (lt <= l && rt >= r) {
    if (id > 0) {
      Set[nw].insert(id);
    } else {
      Set[nw].erase(-id);
    }
    Update(nw, l == r);
    return;
  }
  int mid(l + r >> 1);
  if (lt <= mid) Modify(nw << 1, l, mid, lt, rt, id);
  if (rt > mid) Modify(nw << 1 | 1, mid + 1, r, lt, rt, id);
  Update(nw, 0);
}
void Init() {
  static int b[maxn], c[maxn];
  int tot1(0), tot2(0);
  n = Read();
  for (int i = 1; i <= n; ++i) {
    int x(Read()), y(Read()), xx(Read()), yy(Read());
    b[++tot1] = x;
    b[++tot1] = xx;
    c[++tot2] = y;
    c[++tot2] = yy;
    a[i] = (Rat){x, xx, y, yy, i};
  }
  std::sort(b + 1, b + 1 + tot1);
  std::sort(c + 1, c + 1 + tot2);
  tot1 = std::unique(b + 1, b + 1 + tot1) - b - 1;
  tot2 = std::unique(c + 1, c + 1 + tot2) - c - 1;
  for (int i = 1; i <= n; ++i) {
    int x(a[i].x1), xx(a[i].x2);
    int y(a[i].y1), yy(a[i].y2);
    x = std::lower_bound(b + 1, b + 1 + tot1, x) - b;
    xx = std::lower_bound(b + 1, b + 1 + tot1, xx) - b;
    y = std::lower_bound(c + 1, c + 1 + tot2, y) - c;
    yy = std::lower_bound(c + 1, c + 1 + tot2, yy) - c;
    Q[x].push_back((Qy){y, yy - 1, i});
    Q[xx].push_back((Qy){y, yy - 1, -i});
    a[i] = (Rat){x, xx, y, yy, i};
  }
  int ans(0);
  for (int i = 1; i <= tot1; ++i) {
    for (int j = 0; j < Q[i].size(); ++j) {
      Rat A(a[std::abs(Q[i][j].id)]);
      Modify(1, 1, tot2, A.y1, A.y2 - 1, Q[i][j].id);
    }
    while (mx[1]) {
      ++ans;
      int id(mx[1]);
      mark[id] = 1;
      Rat A(a[id]);
      Modify(1, 1, tot2, A.y1, A.y2 - 1, 0);
    }
  }
  printf("%d\n", ans + 1);
}
int main() {
  Init();
  return 0;
}
