#include <bits/stdc++.h>
using namespace std;
const int LogN = 17, N = 1 << LogN;
int n, x[2][N], y[2][N];
vector<pair<bool, int>> event[2 * N];
void compress(int c[2][N]) {
  vector<int> v;
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < n; j++) {
      v.push_back(c[i][j]);
    }
  }
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < n; j++) {
      c[i][j] = lower_bound(v.begin(), v.end(), c[i][j]) - v.begin();
    }
  }
}
set<int> ans, colors[4 * N];
int maxc[4 * N], minc[4 * N];
void refresh(int p) {
  minc[p] = maxc[p] = -1;
  if (p < 2 * N) {
    minc[p] = min(minc[2 * p], minc[2 * p + 1]);
    maxc[p] = max(maxc[2 * p], maxc[2 * p + 1]);
  }
  if (!colors[p].empty()) {
    int c = *colors[p].rbegin();
    minc[p] = max(minc[p], c);
    if (!ans.count(c)) {
      maxc[p] = max(maxc[p], c);
    }
  }
  if (maxc[p] < minc[p]) {
    maxc[p] = -1;
  }
}
void update(int c, int l, int r, bool ins, int p = 1, int L = 0,
            int R = 2 * n) {
  if (R <= l || r <= L)
    ;
  else if (l <= L && R <= r) {
    if (ins)
      colors[p].insert(c);
    else
      colors[p].erase(c);
  } else {
    int M = (L + R) / 2;
    update(c, l, r, ins, 2 * p, L, M);
    update(c, l, r, ins, 2 * p + 1, M, R);
  }
  refresh(p);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x[0][i] >> y[0][i] >> x[1][i] >> y[1][i];
  }
  compress(x);
  compress(y);
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < n; j++) {
      event[x[i][j]].emplace_back(i, j);
    }
  }
  fill(maxc, maxc + 4 * N, -1);
  fill(minc, minc + 4 * N, -1);
  for (int i = 0; i < 2 * n; i++) {
    for (pair<bool, int> e : event[i]) {
      bool ins = !e.first;
      int c = e.second;
      update(c, y[0][c], y[1][c], ins);
    }
    while (maxc[1] != -1) {
      int c = maxc[1];
      ans.insert(c);
      update(c, y[0][c], y[1][c], true);
    }
  }
  cout << ans.size() + 1 << endl;
}
