#include <bits/stdc++.h>
using namespace std;
void file(string s) {
  freopen((s + ".in").c_str(), "r", stdin);
  freopen((s + ".out").c_str(), "w", stdout);
}
template <typename Tp>
void read(Tp &x) {
  int fh = 1;
  char c = getchar();
  x = 0;
  while (c > '9' || c < '0') {
    if (c == '-') {
      fh = -1;
    }
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 1) + (x << 3) + (c & 15);
    c = getchar();
  }
  x *= fh;
}
int n, m;
int tx[400005], txt, ty[400005], tyt;
int xl[400005], xr[400005], yl[400005], yr[400005];
int vis[400005];
int mx[400005 << 2], mi[400005 << 2];
set<int> st[400005 << 2];
void pushup(int x) {
  mx[x] = max(mx[((x << 1))], mx[((x << 1) | 1)]);
  mi[x] = min(mi[((x << 1))], mi[((x << 1) | 1)]);
  if (st[x].size()) {
    int mxh = *(--st[x].end());
    mi[x] = max(mi[x], mxh);
    if (mxh > mx[x]) {
      if (vis[mxh] || mxh < mi[x])
        mx[x] = -1;
      else
        mx[x] = mxh;
    }
  }
}
void add(int x, int l, int r, int L, int R, int v) {
  if (l > R || r < L) return;
  if (l >= L && r <= R) {
    st[x].insert(v);
    pushup(x);
    return;
  }
  add(((x << 1)), l, ((l + r) >> 1), L, R, v);
  add(((x << 1) | 1), ((l + r) >> 1) + 1, r, L, R, v);
  pushup(x);
}
void del(int x, int l, int r, int L, int R, int v) {
  if (l > R || r < L) return;
  if (l >= L && r <= R) {
    st[x].erase(v);
    pushup(x);
    return;
  }
  del(((x << 1)), l, ((l + r) >> 1), L, R, v);
  del(((x << 1) | 1), ((l + r) >> 1) + 1, r, L, R, v);
  pushup(x);
}
void upd(int x, int l, int r, int L, int R) {
  if (l > R || r < L) return;
  if (l >= L && r <= R) {
    pushup(x);
    return;
  }
  upd(((x << 1)), l, ((l + r) >> 1), L, R);
  upd(((x << 1) | 1), ((l + r) >> 1) + 1, r, L, R);
  pushup(x);
}
struct Oper {
  int l, r, v, typ;
};
vector<Oper> q[400005];
signed main() {
  read(n);
  for (int i = 1; i <= n; ++i) {
    read(xl[i]);
    read(yl[i]);
    read(xr[i]);
    read(yr[i]);
    tx[++txt] = xl[i];
    tx[++txt] = xr[i];
    ty[++tyt] = yl[i];
    ty[++tyt] = yr[i];
  }
  sort(tx + 1, tx + txt + 1);
  txt = unique(tx + 1, tx + txt + 1) - tx - 1;
  sort(ty + 1, ty + tyt + 1);
  tyt = unique(ty + 1, ty + tyt + 1) - ty - 1;
  for (int i = 1; i <= n; ++i) {
    xl[i] = lower_bound(tx + 1, tx + txt + 1, xl[i]) - tx;
    xr[i] = lower_bound(tx + 1, tx + txt + 1, xr[i]) - tx;
    yl[i] = lower_bound(ty + 1, ty + tyt + 1, yl[i]) - ty;
    yr[i] = lower_bound(ty + 1, ty + tyt + 1, yr[i]) - ty;
    q[xl[i]].push_back((Oper){yl[i], yr[i] - 1, i, 1});
    q[xr[i]].push_back((Oper){yl[i], yr[i] - 1, i, -1});
  }
  memset(mx, -1, sizeof(mx));
  memset(mi, -1, sizeof(mi));
  for (int i = 1; i <= txt; ++i) {
    for (auto t : q[i]) {
      if (t.typ == 1)
        add(1, 1, tyt, t.l, t.r, t.v);
      else
        del(1, 1, tyt, t.l, t.r, t.v);
    }
    while (~mx[1]) {
      vis[mx[1]] = 1;
      upd(1, 1, tyt, yl[mx[1]], yr[mx[1]] - 1);
    }
  }
  int ans = 1;
  for (int i = 1; i <= n; ++i) ans += vis[i];
  printf("%d\n", ans);
  return 0;
}
