#include <bits/stdc++.h>
using namespace std;
const int N = 200100;
int a[N], b[N], c[N], d[N], e[N * 2], f[N * 2], cnt, cmt, vis[N * 2];
int mn[N * 16], mx[N * 16], ans, n;
vector<int> vec[N * 2];
set<int> S[N * 16];
void upd(int o) {
  mn[o] = min(mn[o * 2], mn[o * 2 + 1]);
  mx[o] = max(mx[o * 2], mx[o * 2 + 1]);
  if (!S[o].empty()) {
    if (vis[*S[o].rbegin()])
      mn[o] = max(mn[o], *S[o].rbegin());
    else
      mx[o] = max(mx[o], *S[o].rbegin());
  }
  if (mx[o] < mn[o]) mx[o] = 0;
}
int q1, q2, q3;
void mdf(int o, int l, int r) {
  if (q1 <= l && r <= q2) {
    if (q3) {
      if (S[o].count(q3))
        S[o].erase(q3);
      else
        S[o].insert(q3);
    }
    return upd(o);
  }
  int mid = (l + r) / 2;
  if (q1 <= mid) mdf(o * 2, l, mid);
  if (q2 > mid) mdf(o * 2 + 1, mid + 1, r);
  upd(o);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    e[++cnt] = a[i];
    e[++cnt] = c[i];
    f[++cmt] = b[i];
    f[++cmt] = d[i];
  }
  sort(e + 1, e + cnt + 1);
  cnt = unique(e + 1, e + cnt + 1) - e - 1;
  sort(f + 1, f + cmt + 1);
  cmt = unique(f + 1, f + cmt + 1) - f - 1;
  for (int i = 1; i <= n; ++i) {
    a[i] = lower_bound(e + 1, e + cnt + 1, a[i]) - e;
    c[i] = lower_bound(e + 1, e + cnt + 1, c[i]) - e;
    b[i] = lower_bound(f + 1, f + cmt + 1, b[i]) - f;
    d[i] = lower_bound(f + 1, f + cmt + 1, d[i]) - f - 1;
    vec[a[i]].push_back(i);
    vec[c[i]].push_back(i);
  }
  for (int i = 1; i <= cnt; ++i) {
    for (auto j : vec[i]) {
      q1 = b[j];
      q2 = d[j];
      q3 = j;
      mdf(1, 1, cmt);
    }
    for (; mx[1];) {
      vis[mx[1]] = 1;
      ++ans;
      q1 = b[mx[1]];
      q2 = d[mx[1]];
      q3 = 0;
      mdf(1, 1, cmt);
    }
  }
  cout << (ans + 1) << '\n';
  return 0;
}
