#include <bits/stdc++.h>
using namespace std;
const int N = 400005;
struct Rect {
  int x1, y1, x2, y2;
} a[N];
struct TNode {
  set<int> v;
  int mn, mx, l, r;
} t[N << 2];
inline int lc(int pos) { return pos << 1; }
inline int rc(int pos) { return pos << 1 | 1; }
bool vis[N];
int n;
void pushup(int pos) {
  t[pos].mn = min(t[lc(pos)].mn, t[rc(pos)].mn);
  t[pos].mx = max(t[lc(pos)].mx, t[rc(pos)].mx);
  if (!t[pos].v.empty() && *t[pos].v.rbegin() > t[pos].mx)
    t[pos].mx = vis[*t[pos].v.rbegin()] ? 0 : *t[pos].v.rbegin();
  if (!t[pos].v.empty()) t[pos].mn = max(t[pos].mn, *t[pos].v.rbegin());
  if (t[pos].mx < t[pos].mn) t[pos].mx = 0;
}
void build(int pos, int l, int r) {
  t[pos].l = l;
  t[pos].r = r;
  t[pos].mn = 0;
  if (l == r) return;
  int mid = (l + r) >> 1;
  build(lc(pos), l, mid);
  build(rc(pos), mid + 1, r);
  pushup(pos);
}
void modify(int pos, int l, int r, int v, int fl) {
  if (t[pos].l == l && t[pos].r == r) {
    if (fl == 1)
      t[pos].v.insert(v);
    else if (fl == -1)
      t[pos].v.erase(v);
    return pushup(pos);
  }
  int mid = (t[pos].l + t[pos].r) >> 1;
  if (r <= mid)
    modify(lc(pos), l, r, v, fl);
  else if (l > mid)
    modify(rc(pos), l, r, v, fl);
  else
    modify(lc(pos), l, mid, v, fl), modify(rc(pos), mid + 1, r, v, fl);
  pushup(pos);
}
vector<int> q[N];
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  vector<int> xp, yp;
  for (int i = 1; i <= n; i++) {
    cin >> a[i].x1 >> a[i].y1 >> a[i].x2 >> a[i].y2;
    xp.push_back(a[i].x1);
    yp.push_back(a[i].y1);
    xp.push_back(a[i].x2);
    yp.push_back(a[i].y2);
  }
  sort(xp.begin(), xp.end());
  xp.erase(unique(xp.begin(), xp.end()), xp.end());
  sort(yp.begin(), yp.end());
  yp.erase(unique(yp.begin(), yp.end()), yp.end());
  for (int i = 1; i <= n; i++) {
    a[i].x1 = lower_bound(xp.begin(), xp.end(), a[i].x1) - xp.begin() + 1;
    a[i].y1 = lower_bound(yp.begin(), yp.end(), a[i].y1) - yp.begin() + 1;
    a[i].x2 = lower_bound(xp.begin(), xp.end(), a[i].x2) - xp.begin();
    a[i].y2 = lower_bound(yp.begin(), yp.end(), a[i].y2) - yp.begin();
    q[a[i].x1].push_back(i);
    q[a[i].x2 + 1].push_back(-i);
  }
  build(1, 1, int(yp.size()));
  int ans = 1;
  for (int i = 1; i <= int(xp.size()); i++) {
    for (auto &j : q[i]) {
      int p = abs(j);
      modify(1, a[p].y1, a[p].y2, p, j > 0 ? 1 : -1);
    }
    while (t[1].mx) {
      ++ans;
      int p = t[1].mx;
      vis[p] = 1;
      modify(1, a[p].y1, a[p].y2, p, 0);
    }
  }
  cout << ans << endl;
  return 0;
}
