#include <bits/stdc++.h>
using namespace std;
const int inf32 = 0x3f3f3f3f;
const long long inf64 = 0x3f3f3f3f3f3f3f3f;
struct info {
  int l, r, v;
  info() {}
  info(int l, int r, int v) : l(l), r(r), v(v) {}
};
const int xn = 1e5, xa = 2e5;
int n, vis[xn], rx[xn][2], ry[xn][2];
int ax, ay, dx[xa], dy[xa];
vector<info> s[xa];
const int xp = xa * 4;
int mx[xp], mn[xp];
set<int> st[xp];
void pushup(int u, int t) {
  int l = u * 2 + 1, r = l + 1;
  if (t) {
    mx[u] = max(mx[l], mx[r]);
    mn[u] = min(mn[l], mn[r]);
  } else
    mx[u] = mn[u] = -1;
  if (int((st[u]).size())) {
    int k = *st[u].rbegin();
    mn[u] = max(mn[u], k);
    if (k > mx[u]) {
      if (vis[k] or k < mn[u])
        mx[u] = -1;
      else
        mx[u] = k;
    }
  }
}
void modify(int first, int second, int v, int u = 0, int l = 0, int r = ay) {
  if (first <= l and r <= second) {
    if (v >= n)
      st[u].erase(v - n);
    else if (~v)
      st[u].insert(v);
    return pushup(u, r - l > 1);
  }
  int mid = (l + r) / 2;
  if (first < mid) modify(first, second, v, u * 2 + 1, l, mid);
  if (second > mid) modify(first, second, v, u * 2 + 2, mid, r);
  pushup(u, true);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = (0); i < (n); ++i) {
    for (int t = (0); t < (2); ++t) {
      cin >> rx[i][t] >> ry[i][t];
      dx[ax++] = rx[i][t], dy[ay++] = ry[i][t];
    }
  }
  sort(dx, dx + ax), ax = unique(dx, dx + ax) - dx;
  sort(dy, dy + ay), ay = unique(dy, dy + ay) - dy;
  for (int i = (0); i < (n); ++i) {
    for (int t = (0); t < (2); ++t) {
      rx[i][t] = lower_bound(dx, dx + ax, rx[i][t]) - dx;
      ry[i][t] = lower_bound(dy, dy + ay, ry[i][t]) - dy;
    }
    s[rx[i][0]].emplace_back(ry[i][0], ry[i][1], i);
    s[rx[i][1]].emplace_back(ry[i][0], ry[i][1], i + n);
  }
  for (int u = (0); u < (ay * 4); ++u) mx[u] = mn[u] = -1;
  for (int first = (0); first < (ax); ++first) {
    for (const info &u : s[first]) modify(u.l, u.r, u.v);
    while (~mx[0]) {
      vis[mx[0]] = true;
      modify(ry[mx[0]][0], ry[mx[0]][1], -1);
    }
  }
  int res = 1;
  for (int i = (0); i < (n); ++i) res += vis[i];
  cout << res << '\n';
  return 0;
}
