#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long inf = 10000000;
const long long N = 4e5 + 5;
inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; }
inline bool isLeapYear(long long year) {
  return (year % 400 == 0) || (year % 4 == 0 && year % 100 != 0);
}
inline void normal(long long &a) {
  a %= MOD;
  (a < 0) && (a += MOD);
}
inline long long modMul(long long a, long long b) {
  a %= MOD, b %= MOD;
  normal(a), normal(b);
  return (a * b) % MOD;
}
inline long long modAdd(long long a, long long b) {
  a %= MOD, b %= MOD;
  normal(a), normal(b);
  return (a + b) % MOD;
}
inline long long modSub(long long a, long long b) {
  a %= MOD, b %= MOD;
  normal(a), normal(b);
  a -= b;
  normal(a);
  return a;
}
inline long long modPow(long long b, long long p) {
  long long r = 1;
  while (p) {
    if (p & 1) r = modMul(r, b);
    b = modMul(b, b);
    p >>= 1;
  }
  return r;
}
inline long long modInverse(long long a) { return modPow(a, MOD - 2); }
inline long long modDiv(long long a, long long b) {
  return modMul(a, modInverse(b));
}
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
long long x1[N], x2[N], yy1[N], y2[N], ux[N], uy[N], cx, cy, mx[N << 2],
    mn[N << 2], n, id[N];
vector<long long> I[N], E[N];
set<long long> colors[N << 2];
void update(long long node) {
  long long mxv, mxc, mnc;
  if (!colors[node].size())
    mxv = -1;
  else {
    mxv = *(--colors[node].end());
  }
  mxc = max(mx[2 * node], mx[2 * node + 1]);
  mnc = min(mn[2 * node], mn[2 * node + 1]);
  if (mxv > mxc) {
    if (id[mxv] || mxv < mnc) {
      mx[node] = -1;
    } else
      mx[node] = mxv;
  } else
    mx[node] = mxc;
  mn[node] = max(mxv, mnc);
}
void add(long long node, long long b, long long e, long long p, long long mode,
         long long l = 1, long long r = cy) {
  if (b > e) return;
  if (b <= l and e >= r) {
    if (mode == 1)
      colors[node].insert(p);
    else if (mode == -1)
      colors[node].erase(p);
    update(node);
    return;
  }
  if (b <= ((l + r) / 2)) add(2 * node, b, e, p, mode, l, ((l + r) / 2));
  if (e > ((l + r) / 2)) add(2 * node + 1, b, e, p, mode, ((l + r) / 2) + 1, r);
  update(node);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  scanf("%lld", &n);
  memset(mx, -1, sizeof mx);
  for (long long i = 1; i <= n; i++) {
    scanf("%lld %lld", &x1[i], &yy1[i]);
    scanf("%lld %lld", &x2[i], &y2[i]);
    ux[++cx] = x1[i];
    ux[++cx] = x2[i];
    uy[++cy] = yy1[i];
    uy[++cy] = y2[i];
  }
  sort(ux + 1, ux + cx + 1);
  sort(uy + 1, uy + cy + 1);
  cx = unique(ux + 1, ux + 1 + cx) - ux - 1;
  cy = unique(uy + 1, uy + cy + 1) - uy - 1;
  for (long long i = 1; i <= n; i++) {
    x1[i] = lower_bound(ux + 1, ux + cx + 1, x1[i]) - ux;
    x2[i] = lower_bound(ux + 1, ux + cx + 1, x2[i]) - ux;
    yy1[i] = lower_bound(uy + 1, uy + cy + 1, yy1[i]) - uy;
    y2[i] = lower_bound(uy + 1, uy + cy + 1, y2[i]) - uy;
    I[x1[i]].push_back(i);
    E[x2[i]].push_back(i);
  }
  for (long long i = 1; i <= cx; i++) {
    for (auto X : I[i]) add(1, yy1[X], y2[X] - 1, X, 1);
    for (auto X : E[i]) add(1, yy1[X], y2[X] - 1, X, -1);
    while (~mx[1]) {
      long long X = mx[1];
      id[X] = 1;
      add(1, yy1[X], y2[X] - 1, X, 0);
    }
  }
  long long ans = 1;
  for (int i = 1; i <= n; i++) {
    if (id[i]) ans++;
  }
  printf("%lld\n", ans);
  return 0;
}
