#include <bits/stdc++.h>
using namespace std;
template <typename T>
void maxtt(T &t1, T t2) {
  t1 = max(t1, t2);
}
template <typename T>
void mintt(T &t1, T t2) {
  t1 = min(t1, t2);
}
bool debug = 0;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
string direc = "RDLU";
long long ln, lk, lm;
void etp(bool f = 0) {
  puts(f ? "Yes" : "No");
  exit(0);
}
void addmod(int &x, int y, int mod = 998244353) {
  assert(y >= 0);
  x += y;
  if (x >= mod) x -= mod;
  assert(x >= 0 && x < mod);
}
void et() {
  puts("-1");
  exit(0);
}
long long fastPow(long long x, long long y, int mod = 998244353) {
  long long ans = 1;
  while (y > 0) {
    if (y & 1) ans = (x * ans) % mod;
    x = x * x % mod;
    y >>= 1;
  }
  return ans;
}
long long gcd1(long long x, long long y) { return y ? gcd1(y, x % y) : x; }
map<int, int> mpx, mpy;
int cx, cy;
vector<int> e[200005];
struct mb {
  int x1, x2, y1, y2;
  void rd() {
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    mpx[x1];
    mpx[x2];
    mpy[y1];
    mpy[y2];
  }
  void rs(int i) {
    x1 = mpx[x1];
    x2 = mpx[x2];
    y1 = mpy[y1];
    y2 = mpy[y2] - 1;
    e[x1].push_back(i);
    e[x2].push_back(-i);
  }
} q[200005];
set<int> T[200005 * 4];
int mx[200005 * 4], mn[200005 * 4];
int ans;
bool vis[200005];
void Up(int rt, bool fg) {
  if (fg) {
    mx[rt] = mn[rt] = 0;
  } else {
    mx[rt] = max(mx[(rt << 1)], mx[(rt << 1 | 1)]);
    mn[rt] = min(mn[(rt << 1)], mn[(rt << 1 | 1)]);
  }
  if (!T[rt].empty()) {
    int B = *T[rt].rbegin();
    if (!vis[B])
      maxtt(mx[rt], B);
    else
      maxtt(mn[rt], B);
  }
  if (mn[rt] > mx[rt]) mx[rt] = 0;
}
void upt(int rt, int l, int r, int L, int R, int v) {
  if (L <= l && r <= R) {
    if (v > 0) {
      T[rt].insert(v);
    } else {
      T[rt].erase(-v);
    }
    Up(rt, l == r);
    return;
  }
  int mid = (l + r) / 2;
  if (L <= mid) upt((rt << 1), l, mid, L, R, v);
  if (mid < R) upt((rt << 1 | 1), mid + 1, r, L, R, v);
  Up(rt, 0);
}
void fmain(int ID) {
  scanf("%d", &n);
  for (int(i) = 1; (i) <= (int)(n); (i)++) q[i].rd();
  for (auto &p : mpx) p.second = ++cx;
  for (auto &p : mpy) p.second = ++cy;
  for (int(i) = 1; (i) <= (int)(n); (i)++) {
    q[i].rs(i);
  }
  for (int(i) = 1; (i) <= (int)(cx); (i)++) {
    for (int id : e[i]) upt(1, 1, cy, q[abs(id)].y1, q[abs(id)].y2, id);
    while (mx[1]) {
      vis[mx[1]] = 1;
      ans++;
      upt(1, 1, cy, q[mx[1]].y1, q[mx[1]].y2, 0);
    }
  }
  printf("%d\n", ans + 1);
}
int main() {
  int t = 1;
  for (int(i) = 1; (i) <= (int)(t); (i)++) {
    fmain(i);
  }
  return 0;
}
