#include <bits/stdc++.h>
using namespace std;
inline void read(int &x) {
  int v = 0, f = 1;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-')
    f = -1;
  else
    v = (c & 15);
  while (isdigit(c = getchar())) v = (v << 1) + (v << 3) + (c & 15);
  x = v * f;
}
inline void read(long long &x) {
  long long v = 0ll, f = 1ll;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-')
    f = -1;
  else
    v = (c & 15);
  while (isdigit(c = getchar())) v = (v << 1) + (v << 3) + (c & 15);
  x = v * f;
}
inline void readc(char &x) {
  char c;
  while (((c = getchar()) == ' ') || c == '\n')
    ;
  x = c;
}
int n, m, i, j, px[100005], py[100005], qx[100005], qy[100005], vis[100005],
    ans;
vector<int> allx, ally;
set<int> s[800005];
int mx[800005], mi[800005];
void build(int x, int l, int r) {
  mx[x] = 0;
  mi[x] = 0;
  if (l == r) {
    return;
  }
  int mid = (l + r) / 2;
  build(x + x, l, mid);
  build(x + x + 1, mid + 1, r);
}
void pushup(int x, int f) {
  if (f) {
    mx[x] = 0;
    mi[x] = 0;
  } else {
    mx[x] = max(mx[x + x], mx[x + x + 1]);
    mi[x] = min(mi[x + x], mi[x + x + 1]);
  }
  if (!s[x].empty()) {
    if (*s[x].rbegin() >= mi[x]) {
      if (!vis[*s[x].rbegin()]) {
        mx[x] = max(mx[x], *s[x].rbegin());
      }
    }
    mi[x] = max(mi[x], *s[x].rbegin());
    if (mx[x] < mi[x]) mx[x] = 0;
  }
}
void update(int x, int l, int r, int ql, int qr, int y, int c) {
  if (ql <= l && r <= qr) {
    if (c == 1) s[x].insert(y);
    if (c == -1) s[x].erase(y);
    pushup(x, l == r);
    return;
  }
  int mid = (l + r) / 2;
  if (ql <= mid) update(x + x, l, mid, ql, qr, y, c);
  if (qr > mid) update(x + x + 1, mid + 1, r, ql, qr, y, c);
  pushup(x, 0);
}
struct tt {
  int h, l, r, x, c;
} a[200005];
bool cmp(tt x, tt y) { return x.h < y.h; }
int main() {
  read(n);
  ans = 1;
  vis[0] = 1;
  for (((i)) = (1); ((i)) <= ((n)); ((i))++) {
    read(px[i]);
    read(py[i]);
    read(qx[i]);
    read(qy[i]);
    allx.push_back(px[i]);
    allx.push_back(qx[i]);
    ally.push_back(py[i]);
    ally.push_back(qy[i]);
  }
  sort((allx).begin(), (allx).end());
  allx.resize(unique((allx).begin(), (allx).end()) - allx.begin());
  sort((ally).begin(), (ally).end());
  ally.resize(unique((ally).begin(), (ally).end()) - ally.begin());
  build(1, 1, ally.size());
  for (((i)) = (1); ((i)) <= ((n)); ((i))++) {
    px[i] = upper_bound((allx).begin(), (allx).end(), px[i]) - allx.begin();
    qx[i] = upper_bound((allx).begin(), (allx).end(), qx[i]) - allx.begin();
    py[i] = upper_bound((ally).begin(), (ally).end(), py[i]) - ally.begin();
    qy[i] = upper_bound((ally).begin(), (ally).end(), qy[i]) - ally.begin() - 1;
    a[i * 2 - 1] = (tt){px[i], py[i], qy[i], i, 1};
    a[i * 2 - 0] = (tt){qx[i], py[i], qy[i], i, -1};
  }
  sort(a + 1, a + n + n + 1, cmp);
  for (((i)) = (1); ((i)) <= ((n + n)); ((i))++) {
    update(1, 1, ally.size(), a[i].l, a[i].r, a[i].x, a[i].c);
    if (i == n + n || a[i].h != a[i + 1].h) {
      while (mx[1] != 0) {
        ans++;
        vis[mx[1]] = 1;
        update(1, 1, ally.size(), py[mx[1]], qy[mx[1]], mx[1], 0);
      }
    }
  }
  cout << ans << endl;
  return 0;
}
