#include <bits/stdc++.h>
using namespace std;
const int MAXS = 1 << 19;
const int MAXN = 100005;
bool vis[MAXN];
set<int> occ[MAXS];
int mx[MAXS], mn[MAXS];
int Y1[MAXN], Y2[MAXN];
void recalc(int sn) {
  int lsn = sn * 2, rsn = sn * 2 + 1;
  mx[sn] = rsn >= MAXS ? 0 : max(mx[lsn], mx[rsn]);
  mn[sn] = rsn >= MAXS ? 0 : min(mn[lsn], mn[rsn]);
  if (occ[sn].empty()) return;
  int m = *occ[sn].rbegin();
  mn[sn] = max(mn[sn], m);
  if (!vis[m]) mx[sn] = max(mx[sn], m);
  if (mn[sn] > mx[sn]) mx[sn] = 0;
}
void update(int sn, int s, int e, int qs, int qe, int v) {
  if (qs <= s && e <= qe) {
    if (v > 0) {
      occ[sn].insert(v);
    } else {
      occ[sn].erase(-v);
    }
    recalc(sn);
    return;
  }
  int m = (s + e) / 2, lsn = sn * 2, rsn = sn * 2 + 1;
  if (qs <= m) update(lsn, s, m, qs, qe, v);
  if (qe > m) update(rsn, m + 1, e, qs, qe, v);
  recalc(sn);
}
int main() {
  int n;
  scanf("%d", &n);
  map<int, vector<int>> events;
  vector<int> ys;
  for (int i = 1; i <= n; ++i) {
    int x1, x2;
    scanf("%d%d%d%d", &x1, &Y1[i], &x2, &Y2[i]);
    ys.push_back(Y1[i]);
    ys.push_back(Y2[i]);
    events[x1].push_back(i);
    events[x2].push_back(-i);
  }
  sort(ys.begin(), ys.end());
  ys.resize(unique(ys.begin(), ys.end()) - ys.begin());
  for (int i = 1; i <= n; ++i) {
    Y1[i] = lower_bound(ys.begin(), ys.end(), Y1[i]) - ys.begin();
    Y2[i] = lower_bound(ys.begin(), ys.end(), Y2[i]) - ys.begin() - 1;
  }
  int ans = 1;
  for (auto &vec : events) {
    for (int v : vec.second) {
      int i = abs(v);
      update(1, 0, ys.size() - 1, Y1[i], Y2[i], v);
    }
    while (mx[1]) {
      vis[mx[1]] = true;
      ++ans;
      update(1, 0, ys.size() - 1, Y1[mx[1]], Y2[mx[1]], 0);
    }
  }
  printf("%d\n", ans);
}
