#include <bits/stdc++.h>
using namespace std;
const int MAXBUF = 1000005;
char B[MAXBUF], *Si = B, *Ti = B;
inline char getc() {
  if (Si == Ti) Ti = (Si = B) + fread(B, 1, MAXBUF, stdin);
  if (Si == Ti)
    return 0;
  else
    return *Si++;
}
template <class T>
inline void read(T &a) {
  static char c;
  static int f;
  while (((c = getc()) < '0' || c > '9') && (c != '-'))
    ;
  if (c == '-') {
    f = 1;
    a = 0;
  } else {
    f = 0;
    a = c - '0';
  }
  while ((c = getc()) <= '9' && c >= '0') a = (a << 3) + (a << 1) + c - '0';
  if (f) a = -a;
}
priority_queue<int> que[800005];
int maxn[800005], minn[800005], ans = 0, px[200005], py[200005], n, c1 = 0,
                                c2 = 0, a[100005], b[100005], c[100005],
                                d[100005], maxx[800005];
bool vis[100005], ers[100005];
vector<int> vec[200005];
inline int min(int a, int b) { return a < b ? a : b; }
inline int max(int a, int b) { return a > b ? a : b; }
inline void update(int pos) {
  minn[pos] = min(minn[(pos << 1)], minn[(pos << 1 | 1)]);
  maxn[pos] = max(maxn[(pos << 1)], maxn[(pos << 1 | 1)]);
  if (maxx[pos] <= minn[pos]) {
    if (maxn[pos] < minn[pos]) maxn[pos] = 0;
    return;
  }
  minn[pos] = maxx[pos];
  if (maxx[pos] > maxn[pos]) maxn[pos] = (vis[maxx[pos]] ? 0 : maxx[pos]);
}
void modify(int pos, int l, int r, int lp, int rp, int id) {
  if (l == lp && r == rp) {
    if (id > 0) {
      que[pos].push(id);
      maxx[pos] = max(maxx[pos], id);
    }
    if (id < 0) {
      ers[-id] = 1;
      while ((!que[pos].empty()) && ers[que[pos].top()]) que[pos].pop();
      maxx[pos] = (que[pos].empty() ? 0 : que[pos].top());
    }
    if (l == r) {
      if (que[pos].empty()) {
        minn[pos] = maxn[pos] = 0;
        return;
      }
      minn[pos] = maxx[pos];
      maxn[pos] = (vis[maxx[pos]] ? 0 : maxx[pos]);
      return;
    }
    update(pos);
    return;
  }
  int mid = (l + r) >> 1;
  if (lp <= mid) modify((pos << 1), l, mid, lp, min(rp, mid), id);
  if (rp > mid) modify((pos << 1 | 1), mid + 1, r, max(lp, mid + 1), rp, id);
  update(pos);
}
int main() {
  int i, j;
  read(n);
  for (i = 1; i <= n; i++) {
    read(a[i]);
    read(b[i]);
    read(c[i]);
    read(d[i]);
    px[++c1] = a[i];
    px[++c1] = c[i];
    py[++c2] = b[i];
    py[++c2] = d[i];
  }
  sort(px + 1, px + c1 + 1);
  sort(py + 1, py + c2 + 1);
  c1 = unique(px + 1, px + c1 + 1) - px - 1;
  c2 = unique(py + 1, py + c2 + 1) - py - 1;
  for (i = 1; i <= n; i++) {
    a[i] = lower_bound(px + 1, px + c1 + 1, a[i]) - px;
    c[i] = lower_bound(px + 1, px + c1 + 1, c[i]) - px;
    b[i] = lower_bound(py + 1, py + c2 + 1, b[i]) - py;
    d[i] = lower_bound(py + 1, py + c2 + 1, d[i]) - py - 1;
    vec[a[i]].push_back(i);
    vec[c[i]].push_back(-i);
  }
  for (i = 1; i <= c1; i++) {
    int sz = vec[i].size();
    for (j = 0; j < sz; j++) {
      int o = (vec[i][j] < 0 ? -vec[i][j] : vec[i][j]);
      modify(1, 1, c2, b[o], d[o], vec[i][j]);
    }
    while (maxn[1]) {
      vis[maxn[1]] = 1;
      ans++;
      modify(1, 1, c2, b[maxn[1]], d[maxn[1]], 0);
    }
  }
  printf("%d\n", ans + 1);
  return 0;
}
