#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
bool vis[MAXN];
struct Node {
  set<int> colors;
  int minc, maxc;
} seg[MAXN << 3];
void maintain(int left, int right, int x) {
  if (left == right)
    seg[x].minc = seg[x].maxc = -1;
  else {
    seg[x].maxc = max(seg[x << 1].maxc, seg[x << 1 | 1].maxc);
    seg[x].minc = min(seg[x << 1].minc, seg[x << 1 | 1].minc);
  }
  if (!seg[x].colors.empty()) {
    int c = *seg[x].colors.rbegin();
    if (c > seg[x].maxc) {
      if (vis[c] || c < seg[x].minc)
        seg[x].maxc = -1;
      else
        seg[x].maxc = c;
    }
    seg[x].minc = max(seg[x].minc, c);
  }
}
void build(int left, int right, int x) {
  seg[x].minc = seg[x].maxc = -1;
  seg[x].colors.clear();
  if (left == right) return;
  int mid = (left + right) / 2;
  build(left, mid, x << 1);
  build(mid + 1, right, x << 1 | 1);
}
void modify(int c, int l, int r, int left, int right, int x) {
  if (l == left && r == right) {
    if (c > 0)
      seg[x].colors.insert(c);
    else if (c < 0)
      seg[x].colors.erase(-c);
    maintain(left, right, x);
    return;
  }
  int mid = (left + right) / 2;
  if (r <= mid)
    modify(c, l, r, left, mid, x << 1);
  else if (l > mid)
    modify(c, l, r, mid + 1, right, x << 1 | 1);
  else {
    modify(c, l, mid, left, mid, x << 1);
    modify(c, mid + 1, r, mid + 1, right, x << 1 | 1);
  }
  maintain(left, right, x);
}
void debug(int d, int left, int right, int x) {
  for (int i = 0; i < d; i++) printf("  ");
  printf("%d %d: %d %d\n", left, right, seg[x].minc, seg[x].maxc);
  if (left == right) return;
  int mid = (left + right) / 2;
  debug(d + 1, left, mid, x << 1);
  debug(d + 1, mid + 1, right, x << 1 | 1);
}
int n;
pair<int, int> itv[MAXN];
struct Event {
  int x, l, r, c;
  Event(int x, int l, int r, int c) : x(x), l(l), r(r), c(c) {}
};
vector<Event> events;
vector<int> scan;
inline int idx(int x) {
  return upper_bound(scan.begin(), scan.end(), x) - scan.begin();
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int x1, y1, x2, y2;
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    itv[i] = make_pair(y1, y2);
    scan.push_back(y1);
    scan.push_back(y2);
    events.emplace_back(x1, y1, y2, i);
    events.emplace_back(x2, y1, y2, -i);
  }
  sort(scan.begin(), scan.end());
  scan.resize(unique(scan.begin(), scan.end()) - scan.begin());
  int m = scan.size() - 1;
  build(1, m, 1);
  for (int i = 1; i <= n; i++) {
    itv[i].first = idx(itv[i].first);
    itv[i].second = idx(itv[i].second) - 1;
  }
  for (Event& i : events) {
    i.l = idx(i.l);
    i.r = idx(i.r) - 1;
  }
  sort(events.begin(), events.end(),
       [](const Event& a, const Event& b) -> bool { return a.x < b.x; });
  for (int i = 0; i < 2 * n;) {
    do {
      modify(events[i].c, events[i].l, events[i].r, 1, m, 1);
      i++;
    } while (i < 2 * n && events[i].x == events[i - 1].x);
    while (~seg[1].maxc) {
      int c = seg[1].maxc;
      vis[c] = true;
      modify(0, itv[c].first, itv[c].second, 1, m, 1);
    }
  }
  int ans = 1;
  for (int i = 1; i <= n; i++)
    if (vis[i]) ans++;
  printf("%d\n", ans);
  return 0;
}
