#include <bits/stdc++.h>
using namespace std;
int n;
struct st {
  long long int x1;
  long long int y1;
  long long int x2;
  long long int y2;
};
vector<st> v;
vector<long long int> x;
vector<long long int> y;
vector<vector<int> > add;
vector<vector<int> > err;
int mx[100002 * 2 * 4];
int mx2[100002 * 2 * 4];
int mint[100002 * 2 * 4];
priority_queue<int> cov[100002 * 2 * 4];
bool ex[100002 * 2 * 4];
bool look[100002 * 2 * 4];
void clean(priority_queue<int> &q) {
  while (!q.empty() && ex[q.top()] == false) {
    q.pop();
  }
}
inline void enu(int b, int l, int r, int x = -1) {
  if (mx2[b] == -1) {
    return;
  }
  if (mx2[b] < max(mint[b], x)) {
    return;
  }
  clean(cov[b]);
  if (!cov[b].empty()) {
    x = max(x, cov[b].top());
  }
  if (!cov[b].empty()) {
    if (cov[b].top() == max(mint[b], x)) {
      look[cov[b].top()] = true;
    }
  }
  mx2[b] = -1;
  if (l + 1 < r) {
    enu(b * 2 + 1, l, (l + r) >> 1, x);
    enu(b * 2 + 2, (l + r) >> 1, r, x);
    mx2[b] = max(mx2[b * 2 + 1], mx2[b * 2 + 2]);
  }
  if (cov[b].size() && look[cov[b].top()] == false) {
    mx2[b] = max(mx2[b], cov[b].top());
  }
  if (mx2[b] < mint[b]) mx2[b] = -1;
}
inline void ins(int b, int l, int r, int ll, int rr, int x) {
  clean(cov[b]);
  if (r <= ll || rr <= l) return;
  if (ll <= l && r <= rr) {
    cov[b].push(x);
    mx2[b] = max(mx2[b], x);
    mint[b] = max(mint[b], x);
    if (mx2[b] < mint[b]) mx2[b] = -1;
    return;
  }
  mx2[b] = max(mx2[b], x);
  ins(b * 2 + 1, l, (l + r) >> 1, ll, rr, x);
  ins(b * 2 + 2, (l + r) >> 1, r, ll, rr, x);
  mint[b] = min(mint[b * 2 + 1], mint[b * 2 + 2]);
  if (!cov[b].empty()) mint[b] = max(mint[b], cov[b].top());
  if (mx2[b] < mint[b]) mx2[b] = -1;
}
inline void er(int b, int l, int r, int ll, int rr, int x) {
  clean(cov[b]);
  if (r <= ll || rr <= l) return;
  if (ll <= l && r <= rr) {
    mx[b] = mx2[b] = mint[b] = -1;
    if (cov[b].size() && look[cov[b].top()] == false) mx2[b] = cov[b].top();
    if (b * 2 + 2 < 100002 * 2 * 4) {
      mx2[b] = max(mx2[b], max(mx2[b * 2 + 1], mx2[b * 2 + 2]));
      mint[b] = min(mint[b * 2 + 1], mint[b * 2 + 2]);
    }
    if (cov[b].size()) mint[b] = max(cov[b].top(), mint[b]);
    if (mx2[b] < mint[b]) mx2[b] = mint[b];
    return;
  }
  er(b * 2 + 1, l, (l + r) >> 1, ll, rr, x);
  er(b * 2 + 2, (l + r) >> 1, r, ll, rr, x);
  mx2[b] = max(mx2[b * 2 + 1], mx2[b * 2 + 2]);
  mint[b] = min(mint[b * 2 + 1], mint[b * 2 + 2]);
  if (cov[b].size() && look[cov[b].top()] == false)
    mx2[b] = max(mx2[b], cov[b].top());
  if (cov[b].size()) mint[b] = max(mint[b], cov[b].top());
  if (mx2[b] < mint[b]) mx2[b] = -1;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    long long int a, b, c, d;
    scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
    v.push_back({a, b, c, d});
    x.push_back(a);
    x.push_back(c);
    y.push_back(b);
    y.push_back(d);
  }
  sort(x.begin(), x.end());
  sort(y.begin(), y.end());
  x.erase(unique(x.begin(), x.end()), x.end());
  y.erase(unique(y.begin(), y.end()), y.end());
  add.assign(x.size(), vector<int>());
  err.assign(x.size(), vector<int>());
  for (int i = 0; i < v.size(); i++) {
    int x1 = lower_bound(x.begin(), x.end(), v[i].x1) - x.begin();
    int x2 = lower_bound(x.begin(), x.end(), v[i].x2) - x.begin();
    add[x1].push_back(i);
    err[x2].push_back(i);
  }
  memset(mx, -1, sizeof(mx));
  memset(mx2, -1, sizeof(mx2));
  memset(mint, -1, sizeof(mint));
  for (int i = 0; i < x.size(); i++) {
    for (int id : add[i]) {
      ex[id] = true;
      ins(0, 0, y.size(), lower_bound(y.begin(), y.end(), v[id].y1) - y.begin(),
          lower_bound(y.begin(), y.end(), v[id].y2) - y.begin(), id);
    }
    for (int id : err[i]) {
      ex[id] = false;
      er(0, 0, y.size(), lower_bound(y.begin(), y.end(), v[id].y1) - y.begin(),
         lower_bound(y.begin(), y.end(), v[id].y2) - y.begin(), id);
    }
    enu(0, 0, y.size());
  }
  int ans = 1;
  for (int i = 0; i < n; i++) {
    if (look[i]) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
