#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXN = 200007;
const int MAX = 262072;
const int MAXS = MAX * 2 + 7;
bool vis[MAXN];
class stT {
 public:
  stT() {
    memset(mx, -1, sizeof(mx));
    memset(mn, -1, sizeof(mn));
  }
  void add(int l, int r, int x, int now = 1, int ll = 1, int rr = MAX) {
    if (ll >= l && rr <= r)
      col[now].insert(x), upd(now);
    else if (rr < l || ll > r)
      return;
    else {
      int mid = (ll + rr) >> 1;
      add(l, r, x, now << 1, ll, mid);
      add(l, r, x, now << 1 | 1, mid + 1, rr);
      upd(now);
    }
  }
  void del(int l, int r, int x, int now = 1, int ll = 1, int rr = MAX) {
    if (ll >= l && rr <= r)
      col[now].erase(x), upd(now);
    else if (rr < l || ll > r)
      return;
    else {
      int mid = (ll + rr) >> 1;
      del(l, r, x, now << 1, ll, mid);
      del(l, r, x, now << 1 | 1, mid + 1, rr);
      upd(now);
    }
  }
  int query() { return mx[1]; }

 private:
  void upd(int now) {
    mn[now] = max(((col[now].empty()) ? -1 : *col[now].rbegin()),
                  (now < MAX) ? min(mn[now << 1], mn[now << 1 | 1]) : -1);
    int nv = ((col[now].empty()) ? -1 : *col[now].rbegin()),
        cv = (now < MAX) ? max(mx[now << 1], mx[now << 1 | 1]) : -1;
    if (nv > cv)
      mx[now] = (vis[nv] || nv < mn[now]) ? -1 : nv;
    else
      mx[now] = cv;
  }
  set<int> col[MAXS];
  int mx[MAXS], mn[MAXS];
} st;
struct rT {
  int xl, yl, xr, yr;
} rect[MAXN];
struct eT {
  void setd(int _t, int _tp, int _id) { t = _t, tp = _tp, id = _id; }
  bool operator<(const eT &a) const { return t < a.t; }
  int t, tp, id;
} ev[MAXN];
int n;
int stb[MAXN];
void init();
void input();
void work();
int main() {
  init();
  input();
  work();
}
void init() { ios::sync_with_stdio(false); }
void input() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i)
    scanf("%d%d%d%d", &rect[i].xl, &rect[i].yl, &rect[i].xr, &rect[i].yr);
}
void work() {
  for (int i = 1; i <= n; ++i) --rect[i].yr;
  int ks = 0;
  for (int i = 1; i <= n; ++i)
    stb[++ks] = rect[i].yl, stb[++ks] = rect[i].yr + 1;
  sort(stb + 1, stb + 1 + ks);
  ks = unique(stb + 1, stb + 1 + ks) - stb - 1;
  for (int i = 1; i <= n; ++i)
    rect[i].yl = lower_bound(stb + 1, stb + 1 + ks, rect[i].yl) - stb,
    rect[i].yr = upper_bound(stb + 1, stb + 1 + ks, rect[i].yr) - stb - 1;
  int ke = 0;
  for (int i = 1; i <= n; ++i) {
    ev[ke++].setd(rect[i].xl, 1, i);
    ev[ke++].setd(rect[i].xr, 0, i);
  }
  sort(ev, ev + ke);
  ev[ke].t = INF;
  int ni, ret;
  for (int i = 0; i < ke; ++i) {
    ni = ev[i].id;
    if (ev[i].tp)
      st.add(rect[ni].yl, rect[ni].yr, ni);
    else
      st.del(rect[ni].yl, rect[ni].yr, ni);
    if (ev[i].t ^ ev[i + 1].t) {
      while (~(ret = st.query())) {
        st.del(rect[ret].yl, rect[ret].yr, ret);
        vis[ret] = true;
        st.add(rect[ret].yl, rect[ret].yr, ret);
      }
    }
  }
  int ans = 1;
  for (int i = 1; i <= n; ++i)
    if (vis[i]) ++ans;
  cout << ans << endl;
}
