#include <bits/stdc++.h>
using namespace std;
inline int read() {
  char ch = getchar();
  int x = 0, f = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while ('0' <= ch && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
struct block {
  int x1, y1, x2, y2;
} a[100010];
int c[100010 * 2], tt;
struct Node {
  int x, l, r, id;
  inline bool operator<(const Node& rhs) const { return x < rhs.x; }
} q[100010 * 2];
int Ans[100010];
int lim;
int mx[100010 * 16], mn[100010 * 16];
set<int> S[100010 * 16];
inline void maintain(int o) {
  mx[o] = max(mx[2 * o], mx[2 * o + 1]);
  mn[o] = min(mn[2 * o], mn[2 * o + 1]);
  if (!S[o].empty()) {
    int x = *--S[o].end();
    if (x > mx[o]) {
      if (Ans[x] || x < mn[o])
        mx[o] = 0;
      else
        mx[o] = x;
    }
    mn[o] = max(mn[o], x);
  }
}
inline void Add(int l, int r, int o, int x, int y, int z) {
  if (x <= l && r <= y) {
    if (z > 0) S[o].insert(z);
    if (z < 0) S[o].erase(-z);
    maintain(o);
    return;
  }
  int mid = (l + r) / 2;
  if (x <= mid) Add(l, mid, 2 * o, x, y, z);
  if (y > mid) Add(mid + 1, r, 2 * o + 1, x, y, z);
  maintain(o);
}
int main() {
  int n = read();
  for (int i = 1; i <= n; ++i) {
    a[i] = (block){read(), read(), read(), read()};
  }
  for (int i = 1; i <= n; ++i) {
    c[++tt] = a[i].y1;
    c[++tt] = a[i].y2;
  }
  sort(c + 1, c + tt + 1);
  tt = unique(c + 1, c + tt + 1) - c - 1;
  for (int i = 1; i <= n; ++i) {
    a[i].y1 = lower_bound(c + 1, c + tt + 1, a[i].y1) - c;
    a[i].y2 = lower_bound(c + 1, c + tt + 1, a[i].y2) - c;
  }
  lim = tt;
  tt = 0;
  for (int i = 1; i <= n; ++i) {
    q[++tt] = (Node){a[i].x1, a[i].y1, a[i].y2 - 1, i};
    q[++tt] = (Node){a[i].x2, a[i].y1, a[i].y2 - 1, -i};
  }
  sort(q + 1, q + tt + 1);
  for (int i = 1; i <= tt; ++i) {
    Add(1, lim, 1, q[i].l, q[i].r, q[i].id);
    if (q[i].x != q[i + 1].x || i == tt) {
      while (mx[1] != 0) {
        Ans[mx[1]] = 1;
        Add(1, lim, 1, a[mx[1]].y1, a[mx[1]].y2 - 1, 0);
      }
    }
  }
  int res = 1;
  for (int i = 1; i <= n; ++i) {
    if (Ans[i]) ++res;
  }
  printf("%d\n", res);
}
