#include <bits/stdc++.h>
using namespace std;
const int inf = 0x7fffffff;
const double eps = 1e-10;
const double pi = acos(-1.0);
inline int read() {
  int x = 0, f = 1;
  char ch;
  ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = 0;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 1) + (x << 3) + (ch & 15);
    ch = getchar();
  }
  if (f)
    return x;
  else
    return -x;
}
const int N = 100010;
bool used[N << 3];
struct Segment_Tree {
  int Max[N << 3], Min[N << 3];
  set<int> Sum[N << 3];
  void PushUp(int rt, int l, int r) {
    Max[rt] = (l == r ? 0 : max(Max[rt << 1], Max[rt << 1 | 1]));
    Min[rt] = (l == r ? 0 : min(Min[rt << 1], Min[rt << 1 | 1]));
    if (!Sum[rt].empty()) {
      int g = *Sum[rt].rbegin();
      if (!used[g])
        Max[rt] = max(Max[rt], g);
      else
        Min[rt] = max(Min[rt], g);
    }
    if (Min[rt] > Max[rt]) Max[rt] = 0;
  }
  void PushDown(int L, int R, int l, int r, int rt) {
    if (L <= l && r <= R) {
      PushUp(rt, l, r);
      return;
    }
    int mid = (l + r) >> 1;
    if (L <= mid) PushDown(L, R, l, mid, rt << 1);
    if (R > mid) PushDown(L, R, mid + 1, r, rt << 1 | 1);
    PushUp(rt, l, r);
  }
  void update(int L, int R, long long c, int l, int r, int rt) {
    if (L <= l && r <= R) {
      if (c > 0)
        Sum[rt].insert(c);
      else
        Sum[rt].erase(-c);
      PushUp(rt, l, r);
      return;
    }
    int mid = (l + r) >> 1;
    if (L <= mid) update(L, R, c, l, mid, rt << 1);
    if (R > mid) update(L, R, c, mid + 1, r, rt << 1 | 1);
    PushUp(rt, l, r);
  }
} Seg;
map<int, int> mpx, mpy;
map<int, int>::iterator it;
int x1[N], Y1[N], x2[N], y2[N];
struct Segment {
  int l, r, v;
};
vector<Segment> v[N << 1];
int n;
int lenx = 1, leny = 1;
void lisan() {
  for (int i = 1; i <= n; i++) {
    mpx[x1[i]] = 1;
    mpy[Y1[i]] = 1;
    mpx[x2[i]] = 1;
    mpy[y2[i]] = 1;
  }
  for (it = mpx.begin(); it != mpx.end(); it++) it->second = lenx, lenx++;
  for (it = mpy.begin(); it != mpy.end(); it++) it->second = leny, leny++;
  lenx--;
  leny--;
  for (int i = 1; i <= n; i++) {
    x1[i] = mpx[x1[i]];
    Y1[i] = mpy[Y1[i]];
    x2[i] = mpx[x2[i]];
    y2[i] = mpy[y2[i]] - 1;
  }
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) {
    x1[i] = read();
    Y1[i] = read();
    x2[i] = read();
    y2[i] = read();
  }
  lisan();
  for (int i = 1; i <= n; i++) {
    v[x1[i]].push_back((Segment){Y1[i], y2[i], i});
    v[x2[i]].push_back((Segment){Y1[i], y2[i], -i});
  }
  int ans = 0;
  for (int i = 1; i <= lenx; i++) {
    for (int j = 0; j < v[i].size(); j++)
      Seg.update(v[i][j].l, v[i][j].r, v[i][j].v, 1, leny, 1);
    while (Seg.Max[1]) {
      used[Seg.Max[1]] = 1;
      ans++;
      Seg.PushDown(Y1[Seg.Max[1]], y2[Seg.Max[1]], 1, leny, 1);
    }
  }
  printf("%d\n", ans + 1);
  return 0;
}
