#include <bits/stdc++.h>
using namespace std;
int read() {
  char ch = getchar();
  int x = 0, op = 1;
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') op = -1;
  for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + ch - '0';
  return x * op;
}
int n, x1[200005], x2[200005], y1_[200005], y2[200005], numx[200005],
    numy[200005], cx, cy, mx[200005 << 2], mi[200005 << 2], ans;
bool vis[200005 << 2];
vector<int> q[200005];
set<int> s[200005 << 2];
void up(int o, int l, int r) {
  if (l == r)
    mx[o] = mi[o] = 0;
  else
    mx[o] = max(mx[(o << 1)], mx[(o << 1 | 1)]),
    mi[o] = min(mi[(o << 1)], mi[(o << 1 | 1)]);
  if (((int)(s[o]).size())) {
    int val;
    if (!vis[val = *s[o].rbegin()])
      mx[o] = max(mx[o], val);
    else
      mi[o] = max(mi[o], val);
  }
  if (mi[o] > mx[o]) mx[o] = 0;
}
void ins(int o, int l, int r, int x, int y, int val) {
  if (x <= l && r <= y) {
    if (val)
      if (val > 0)
        s[o].insert(val);
      else
        s[o].erase(-val);
    up(o, l, r);
    return;
  }
  int mid = l + r >> 1;
  if (x <= mid) ins((o << 1), l, mid, x, y, val);
  if (y > mid) ins((o << 1 | 1), mid + 1, r, x, y, val);
  up(o, l, r);
}
int main() {
  n = read();
  for (int i = (1); i <= (n); i++) {
    numx[++cx] = x1[i] = read(), numy[++cy] = y1_[i] = read();
    numx[++cx] = x2[i] = read(), numy[++cy] = y2[i] = read();
  }
  sort(&numx[1], &numx[cx + 1]);
  cx = unique(&numx[1], &numx[cx + 1]) - numx - 1;
  sort(&numy[1], &numy[cy + 1]);
  cy = unique(&numy[1], &numy[cy + 1]) - numy - 1;
  for (int i = (1); i <= (n); i++) {
    x1[i] = lower_bound(&numx[1], &numx[cx + 1], x1[i]) - numx;
    x2[i] = lower_bound(&numx[1], &numx[cx + 1], x2[i]) - numx;
    y1_[i] = lower_bound(&numy[1], &numy[cy + 1], y1_[i]) - numy;
    y2[i] = lower_bound(&numy[1], &numy[cy + 1], y2[i]) - numy - 1;
    q[x1[i]].push_back(i);
    q[x2[i]].push_back(-i);
  }
  for (int i = (1); i <= (cx); i++) {
    for (auto j : q[i]) ins(1, 1, cy, y1_[abs(j)], y2[abs(j)], j);
    while (mx[1]) {
      vis[mx[1]] = 1;
      ans++;
      ins(1, 1, cy, y1_[mx[1]], y2[mx[1]], 0);
    }
  }
  cout << ans + 1 << '\n';
  return 0;
}
