#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T& x) {
  char c = getchar();
  bool f = false;
  for (x = 0; !isdigit(c); c = getchar()) {
    if (c == '-') {
      f = true;
    }
  }
  for (; isdigit(c); c = getchar()) {
    x = x * 10 + c - '0';
  }
  if (f) {
    x = -x;
  }
}
template <typename T, typename... U>
inline void read(T& x, U&... y) {
  read(x), read(y...);
}
const int N = 2e5 + 10;
int n, m, cnt;
int V[N], U[N], D[N], MAXV[N << 2], MINV[N << 2];
bool vis[N];
map<int, int> S;
set<int> G[N << 2];
struct Data {
  int x, y1, y2, col;
  Data() {}
  Data(int a, int b, int c, int d) : x(a), y1(b), y2(c), col(d) {}
} A[N];
struct SegmentTree {
  void Pushup(int l, int r, int o) {
    if (l == r)
      MAXV[o] = MINV[o] = 0;
    else
      MAXV[o] = max(MAXV[o << 1], MAXV[o << 1 | 1]),
      MINV[o] = min(MINV[o << 1], MINV[o << 1 | 1]);
    if (G[o].size()) {
      if (vis[*G[o].rbegin()])
        MINV[o] = max(MINV[o], *G[o].rbegin());
      else
        MAXV[o] = max(MAXV[o], *G[o].rbegin());
    }
    if (MAXV[o] < MINV[o]) MAXV[o] = 0;
  }
  void Modify(int l, int r, int o, int ql, int qr, int v) {
    if (ql <= l && r <= qr) {
      if (v > 0)
        G[o].insert(v);
      else if (v < 0)
        G[o].erase(G[o].find(-v));
      return Pushup(l, r, o);
    }
    int mid = l + r >> 1;
    if (ql <= mid) Modify(l, mid, o << 1, ql, qr, v);
    if (qr > mid) Modify(mid + 1, r, o << 1 | 1, ql, qr, v);
    Pushup(l, r, o);
  }
} SgT;
bool cmp(Data A, Data B) { return A.x < B.x; }
int main() {
  read(n);
  for (int i = 1; i <= n; ++i) {
    int x1, y1, x2, y2;
    read(x1, y1, x2, y2);
    A[++m] = Data(x1, y1, y2, i);
    A[++m] = Data(x2, y1, y2, -i);
    V[++cnt] = y1;
    V[++cnt] = y2;
    D[i] = y1;
    U[i] = y2;
  }
  sort(V + 1, V + cnt + 1);
  sort(A + 1, A + m + 1, cmp);
  cnt = unique(V + 1, V + cnt + 1) - V - 1;
  for (int i = 1; i <= cnt; ++i) S[V[i]] = i;
  int res = 1;
  for (int i = 1; i <= m; ++i) {
    int p = i;
    while (p != m && A[p + 1].x == A[i].x) ++p;
    for (int j = i; j <= p; ++j)
      SgT.Modify(1, cnt, 1, S[A[j].y1], S[A[j].y2] - 1, A[j].col);
    while (MAXV[1]) {
      ++res;
      vis[MAXV[1]] = true;
      SgT.Modify(1, cnt, 1, S[D[MAXV[1]]], S[U[MAXV[1]]] - 1, 0);
    }
    i = p;
  }
  printf("%d\n", res);
  return 0;
}
