#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 3e5 + 5;
struct rect {
  int x1, x2, y1, y2;
} g[maxn];
vector<int> fx, fy;
vector<pair<int, int> > w[maxn];
bool eras[maxn], vis[maxn];
struct node {
  int u, v;
  set<int> d;
  void reset() {
    while (!d.empty() && eras[-(*d.begin())]) d.erase(d.begin());
    if (!d.empty()) {
      u = max(u, -(*d.begin()));
      v = max(v, -(*d.begin()));
    }
    if (v < u) v = -1;
    if (v != -1 && vis[v]) v = -1;
  }
} f[maxn << 2];
void update(int t, bool fg) {
  if (fg)
    f[t].v = f[t].u = -1;
  else {
    f[t].v = max(f[t << 1].v, f[t << 1 | 1].v);
    f[t].u = min(f[t << 1].u, f[t << 1 | 1].u);
  }
  f[t].reset();
}
void add(int t, int l, int r, int ll, int rr, int v, int op) {
  if (ll <= l && r <= rr) {
    if (op == 1) f[t].d.insert(-v);
    update(t, l == r);
    return;
  }
  int mid = (l + r) >> 1;
  if (ll <= mid) add(t << 1, l, mid, ll, rr, v, op);
  if (rr > mid) add(t << 1 | 1, mid + 1, r, ll, rr, v, op);
  update(t, l == r);
}
int main() {
  int n, m, i, x1, x2, y1, y2, ans = 1;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    x2--;
    g[i] = rect{x1, x2, y1, y2};
    fx.push_back(x1);
    fx.push_back(x2);
    fx.push_back(x2 + 1);
    fy.push_back(y1);
    fy.push_back(y2);
  }
  sort(fx.begin(), fx.end());
  sort(fy.begin(), fy.end());
  fx.erase(unique(fx.begin(), fx.end()), fx.end());
  fy.erase(unique(fy.begin(), fy.end()), fy.end());
  m = fx.size();
  for (i = 1; i <= n; i++) {
    g[i].x1 = lower_bound(fx.begin(), fx.end(), g[i].x1) - fx.begin() + 1;
    g[i].x2 = lower_bound(fx.begin(), fx.end(), g[i].x2) - fx.begin() + 1;
    g[i].y1 = lower_bound(fy.begin(), fy.end(), g[i].y1) - fy.begin() + 1;
    g[i].y2 = lower_bound(fy.begin(), fy.end(), g[i].y2) - fy.begin() + 1;
    w[g[i].y1].push_back(pair<int, int>(i, 1));
    w[g[i].y2].push_back(pair<int, int>(i, -1));
  }
  for (i = 0; i < maxn * 4; i++) f[i].u = f[i].v = -1;
  for (i = 1; i < maxn; i++) {
    if (i > fy.size()) break;
    for (auto e : w[i]) {
      if (e.second == -1) eras[e.first] = 1;
      add(1, 1, m, g[e.first].x1, g[e.first].x2, e.first, e.second);
    }
    while (f[1].v != -1) {
      vis[f[1].v] = 1;
      ans++;
      add(1, 1, m, g[f[1].v].x1, g[f[1].v].x2, f[1].v, 0);
    }
  }
  printf("%d\n", ans);
  return 0;
}
