#include <bits/stdc++.h>
using namespace std;
char buf[1 << 21], *p1 = buf, *p2 = buf;
inline int read() {
  int s = 0, w = 1;
  char ch = getchar();
  while (ch < 48 || ch > 57) {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= 48 && ch <= 57)
    s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
  return s * w;
}
template <typename T>
inline void Max(T &a, T b) {
  if (a < b) a = b;
}
template <typename T>
inline void Min(T &a, T b) {
  if (a > b) a = b;
}
const int N = 2e5 + 7;
int n, ndc, vc, V[N], xl[N], xr[N], yl[N], yr[N];
int mx[N << 2], mi[N << 2];
bool vis[N];
struct qs {
  int p, l, r, opt;
  bool operator<(const qs &rhs) const {
    if (p != rhs.p) return p < rhs.p;
    return opt < rhs.opt;
  }
} q[N];
struct Heap {
  priority_queue<int> A, B;
  void ins(int x) { A.push(x); }
  void del(int x) { B.push(x); }
  inline int top() {
    while (!B.empty() && A.top() == B.top()) A.pop(), B.pop();
    return A.empty() ? 0 : A.top();
  }
} col[N << 2];
inline void pushup(int l, int r, int o) {
  if (l ^ r) {
    mi[o] = min(mi[o << 1], mi[o << 1 | 1]);
    mx[o] = max(mx[o << 1], mx[o << 1 | 1]);
  } else
    mi[o] = mx[o] = 0;
  if (col[o].top()) {
    int x = col[o].top();
    if (vis[x])
      Max(mi[o], x);
    else
      Max(mx[o], x);
    if (mi[o] > mx[o]) mx[o] = 0;
  }
}
void modify(int L, int R, int l, int r, int o, int v) {
  if (L <= l && r <= R) {
    if (v > 0) col[o].ins(v);
    if (v < 0) col[o].del(-v);
    pushup(l, r, o);
    return;
  }
  int mid = (l + r) >> 1;
  if (L <= mid) modify(L, R, l, mid, o << 1, v);
  if (R > mid) modify(L, R, mid + 1, r, o << 1 | 1, v);
  pushup(l, r, o);
}
signed main() {
  n = read();
  for (register int i = 1; i <= n; ++i) {
    xl[i] = read(), yl[i] = read();
    xr[i] = read(), yr[i] = read();
    q[++ndc] = (qs){xl[i], yl[i], yr[i] - 1, i};
    q[++ndc] = (qs){xr[i], yl[i], yr[i] - 1, -i};
    V[++vc] = yl[i];
    V[++vc] = yr[i];
  }
  sort(V + 1, V + vc + 1);
  sort(q + 1, q + ndc + 1);
  vc = unique(V + 1, V + vc + 1) - V - 1;
  for (register int i = 1; i <= n; ++i) {
    yl[i] = lower_bound(V + 1, V + vc + 1, yl[i]) - V;
    yr[i] = upper_bound(V + 1, V + vc + 1, yr[i] - 1) - V - 1;
  }
  for (register int i = 1; i <= ndc; ++i) {
    q[i].l = lower_bound(V + 1, V + vc + 1, q[i].l) - V;
    q[i].r = upper_bound(V + 1, V + vc + 1, q[i].r) - V - 1;
  }
  for (int i = 1, j = 1; i <= ndc; i = j) {
    for (; j <= ndc && q[j].p == q[i].p; ++j)
      modify(q[j].l, q[j].r, 1, vc, 1, q[j].opt);
    while (mx[1]) {
      int x = mx[1];
      vis[x] = 1;
      modify(yl[x], yr[x], 1, vc, 1, 0);
    }
  }
  int ans = 1;
  for (register int i = 1; i <= n; ++i)
    if (vis[i]) ++ans;
  cout << ans << endl;
  return 0;
}
