#include <bits/stdc++.h>
using namespace std;
template <typename T>
void dbg(T a) {}
template <typename T, typename... Arg>
void dbg(T a, Arg... arg) {}
const int maxn = (1e6) + 7;
const int inf = (1e9) + 7;
const long long LLinf = (1e18) + 7;
const long double eps = 1e-9;
const long long mod = 1e9 + 7;
const int pot = 1 << 20;
int x1[maxn], x2[maxn], yy1[maxn], y2[maxn];
int odp[maxn];
map<int, int> mapa, mapa2;
vector<int> V[maxn];
int mi[2 * pot + 7], ma[2 * pot + 7];
set<int> tre[2 * pot + 7];
void lisc(int x) {
  mi[x] = ma[x] = -1;
  if (((int)(tre[x]).size()) > 0) ma[x] = mi[x] = -(*tre[x].begin());
  if (ma[x] > -1 && odp[ma[x]] == 1) ma[x] = -1;
}
void update(int cur) {
  if (cur >= pot) {
    lisc(cur);
    cur /= 2;
  }
  while (cur > 0) {
    mi[cur] = min(mi[2 * cur], mi[2 * cur + 1]);
    if (((int)(tre[cur]).size()) > 0)
      mi[cur] = max(mi[cur], -(*tre[cur].begin()));
    if (((int)(tre[cur]).size()) > 0 &&
        max(ma[2 * cur], ma[2 * cur + 1]) < -(*tre[cur].begin())) {
      if (odp[-(*tre[cur].begin())] == 1 ||
          (-(*tre[cur].begin())) < min(mi[2 * cur], mi[2 * cur + 1]))
        ma[cur] = -1;
      else
        ma[cur] = (-(*tre[cur].begin()));
    } else
      ma[cur] = max(ma[2 * cur], ma[2 * cur + 1]);
    cur /= 2;
  }
}
void dodaj(int l, int p, int kto) {
  l += pot;
  p += pot;
  while (l <= p) {
    if (l & 1) {
      tre[l].insert(-kto);
      update(l);
    }
    if (!(p & 1)) {
      tre[p].insert(-kto);
      update(p);
    }
    l = (l + 1) / 2;
    p = (p - 1) / 2;
  }
}
void usun(int l, int p, int kto) {
  l += pot;
  p += pot;
  while (l <= p) {
    if (l & 1) {
      tre[l].erase(-kto);
      update(l);
    }
    if (!(p & 1)) {
      tre[p].erase(-kto);
      update(p);
    }
    l = (l + 1) / 2;
    p = (p - 1) / 2;
  }
}
void akt(int kto) {
  int l = yy1[kto] + pot;
  int p = y2[kto] + pot;
  while (l <= p) {
    if (l & 1) update(l);
    if (!(p & 1)) update(p);
    l = (l + 1) / 2;
    p = (p - 1) / 2;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> x1[i] >> yy1[i] >> x2[i] >> y2[i];
    if (x1[i] > x2[i]) swap(x1[i], x2[i]);
    if (yy1[i] > y2[i]) swap(yy1[i], y2[i]);
    mapa[yy1[i]] = 1;
    mapa[y2[i]] = 1;
    mapa2[x1[i]] = 1;
    mapa2[x2[i]] = 1;
  }
  int num = 0;
  for (auto &s : mapa) s.second = num++;
  num = 0;
  for (auto &s : mapa2) s.second = num++;
  for (int i = 1; i <= n; i++) {
    x1[i] = mapa2[x1[i]];
    x2[i] = mapa2[x2[i]];
    yy1[i] = mapa[yy1[i]];
    y2[i] = mapa[y2[i]];
    y2[i]--;
    V[x1[i]].push_back(i);
    V[x2[i]].push_back(-i);
  }
  for (int i = 0; i < num; i++) {
    for (auto s : V[i])
      if (s < 0)
        usun(yy1[-s], y2[-s], -s);
      else
        dodaj(yy1[s], y2[s], s);
    while (ma[1] > 0) {
      odp[ma[1]] = 1;
      akt(ma[1]);
    }
  }
  int res = 1;
  for (int i = 1; i <= n; i++)
    if (odp[i] == 1) res++;
  cout << res;
  return 0;
}
