#include <bits/stdc++.h>
using namespace std;
const int mo = 998244353;
const double PI = acos(-1.0);
template <typename _T>
_T Fabs(_T x) {
  return x < 0 ? -x : x;
}
template <typename _T>
void read(_T &x) {
  _T f = 1;
  x = 0;
  char s = getchar();
  while (s > '9' || s < '0') {
    if (s == '-') f = -1;
    s = getchar();
  }
  while ('0' <= s && s <= '9') {
    x = (x << 3) + (x << 1) + (s ^ 48);
    s = getchar();
  }
  x *= f;
}
int n, b[400005 * 2], totx, d[400005 * 2], toty, ans;
bool vis[400005];
set<int> st[400005 << 2];
int maxx[400005 << 2], minn[400005 << 2];
struct ming {
  int ax, ay, bx, by;
} s[400005];
struct node {
  int l, r, val;
};
vector<node> vec[400005];
void updata(int rt, bool fg) {
  if (fg)
    maxx[rt] = minn[rt] = 0;
  else
    maxx[rt] = max(maxx[rt << 1], maxx[rt << 1 | 1]),
    minn[rt] = min(minn[rt << 1], minn[rt << 1 | 1]);
  if (!st[rt].empty()) {
    int t = *st[rt].rbegin();
    if (vis[t])
      minn[rt] = max(minn[rt], t);
    else
      maxx[rt] = max(maxx[rt], t);
  }
  if (minn[rt] > maxx[rt]) maxx[rt] = 0;
}
void insert(int rt, int l, int r, int al, int ar, int aw) {
  if (al <= l && r <= ar) {
    if (aw > 0)
      st[rt].insert(aw);
    else
      st[rt].erase(-aw);
    updata(rt, l == r);
    return;
  }
  int mid = l + r >> 1;
  if (al <= mid) insert(rt << 1, l, mid, al, ar, aw);
  if (ar > mid) insert(rt << 1 | 1, mid + 1, r, al, ar, aw);
  updata(rt, 0);
}
signed main() {
  read(n);
  for (int i = 1; i <= n; i++)
    read(s[i].ax), read(s[i].ay), read(s[i].bx), read(s[i].by);
  for (int i = 1; i <= n; i++) b[++totx] = s[i].ax, b[++totx] = s[i].bx;
  sort(b + 1, b + totx + 1);
  totx = unique(b + 1, b + totx + 1) - b - 1;
  for (int i = 1; i <= n; i++)
    s[i].ax = lower_bound(b + 1, b + totx + 1, s[i].ax) - b,
    s[i].bx = lower_bound(b + 1, b + totx + 1, s[i].bx) - b;
  for (int i = 1; i <= n; i++) d[++toty] = s[i].ay, d[++toty] = s[i].by;
  sort(d + 1, d + toty + 1);
  toty = unique(d + 1, d + toty + 1) - d - 1;
  for (int i = 1; i <= n; i++)
    s[i].ay = lower_bound(d + 1, d + toty + 1, s[i].ay) - d,
    s[i].by = lower_bound(d + 1, d + toty + 1, s[i].by) - d - 1;
  for (int i = 1; i <= n; i++)
    vec[s[i].ax].push_back((node){s[i].ay, s[i].by, i}),
        vec[s[i].bx].push_back((node){s[i].ay, s[i].by, -i});
  for (int i = 1; i <= totx; i++) {
    int siz = vec[i].size();
    for (int j = 0; j < siz; j++)
      insert(1, 1, toty, vec[i][j].l, vec[i][j].r, vec[i][j].val);
    while (maxx[1])
      vis[maxx[1]] = 1, insert(1, 1, toty, s[maxx[1]].ay, s[maxx[1]].by, 0),
      ans++;
  }
  printf("%d\n", ans + 1);
  return 0;
}
