Arkady has got an infinite plane painted in color 0. Then he draws n rectangles filled with paint with sides parallel to the Cartesian coordinate axes, one after another. The color of the i-th rectangle is i (rectangles are enumerated from 1 to n in the order he draws them). It is possible that new rectangles cover some of the previous ones completely or partially.

Count the number of different colors on the plane after Arkady draws all the rectangles.

Input

The first line contains a single integer n (1 ≤ n ≤ 100 000) — the number of rectangles.

The i-th of the next n lines contains 4 integers x_1, y_1, x_2 and y_2 (-10^9 ≤ x_1 < x_2 ≤ 10^9, -10^9 ≤ y_1 < y_2 ≤ 10^9) — the coordinates of corners of the i-th rectangle.

Output

In the single line print the number of different colors in the plane, including color 0.

Examples

Input

5
-1 -1 1 1
-4 0 0 4
0 0 4 4
-4 -4 0 0
0 -4 4 0


Output

5

Input

4
0 0 4 4
-4 -4 0 0
0 -4 4 0
-2 -4 2 4


Output

5

Note

<image> That's how the plane looks in the first sample

<image> That's how the plane looks in the second sample

0 = white, 1 = cyan, 2 = blue, 3 = purple, 4 = yellow, 5 = red. 
#include <bits/stdc++.h>
using namespace std;
template <typename T>
void dbg(T a) {}
template <typename T, typename... Arg>
void dbg(T a, Arg... arg) {}
const int maxn = (1e6) + 7;
const int inf = (1e9) + 7;
const long long LLinf = (1e18) + 7;
const long double eps = 1e-9;
const long long mod = 1e9 + 7;
const int pot = 1 << 20;
int x1[maxn], x2[maxn], yy1[maxn], y2[maxn];
int odp[maxn];
map<int, int> mapa, mapa2;
vector<int> V[maxn];
int mi[2 * pot + 7], ma[2 * pot + 7];
set<int> tre[2 * pot + 7];
void lisc(int x) {
  mi[x] = ma[x] = -1;
  if (((int)(tre[x]).size()) > 0) ma[x] = mi[x] = -(*tre[x].begin());
  if (ma[x] > -1 && odp[ma[x]] == 1) ma[x] = -1;
}
void update(int cur) {
  if (cur >= pot) {
    lisc(cur);
    cur /= 2;
  }
  while (cur > 0) {
    mi[cur] = min(mi[2 * cur], mi[2 * cur + 1]);
    if (((int)(tre[cur]).size()) > 0)
      mi[cur] = max(mi[cur], -(*tre[cur].begin()));
    if (((int)(tre[cur]).size()) > 0 &&
        max(ma[2 * cur], ma[2 * cur + 1]) < -(*tre[cur].begin())) {
      if (odp[-(*tre[cur].begin())] == 1 ||
          (-(*tre[cur].begin())) < min(mi[2 * cur], mi[2 * cur + 1]))
        ma[cur] = -1;
      else
        ma[cur] = (-(*tre[cur].begin()));
    } else
      ma[cur] = max(ma[2 * cur], ma[2 * cur + 1]);
    cur /= 2;
  }
}
void dodaj(int l, int p, int kto) {
  l += pot;
  p += pot;
  while (l <= p) {
    if (l & 1) {
      tre[l].insert(-kto);
      update(l);
    }
    if (!(p & 1)) {
      tre[p].insert(-kto);
      update(p);
    }
    l = (l + 1) / 2;
    p = (p - 1) / 2;
  }
}
void usun(int l, int p, int kto) {
  l += pot;
  p += pot;
  while (l <= p) {
    if (l & 1) {
      tre[l].erase(-kto);
      update(l);
    }
    if (!(p & 1)) {
      tre[p].erase(-kto);
      update(p);
    }
    l = (l + 1) / 2;
    p = (p - 1) / 2;
  }
}
void akt(int kto) {
  int l = yy1[kto] + pot;
  int p = y2[kto] + pot;
  while (l <= p) {
    if (l & 1) update(l);
    if (!(p & 1)) update(p);
    l = (l + 1) / 2;
    p = (p - 1) / 2;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> x1[i] >> yy1[i] >> x2[i] >> y2[i];
    if (x1[i] > x2[i]) swap(x1[i], x2[i]);
    if (yy1[i] > y2[i]) swap(yy1[i], y2[i]);
    mapa[yy1[i]] = 1;
    mapa[y2[i]] = 1;
    mapa2[x1[i]] = 1;
    mapa2[x2[i]] = 1;
  }
  int num = 0;
  for (auto &s : mapa) s.second = num++;
  num = 0;
  for (auto &s : mapa2) s.second = num++;
  for (int i = 1; i <= n; i++) {
    x1[i] = mapa2[x1[i]];
    x2[i] = mapa2[x2[i]];
    yy1[i] = mapa[yy1[i]];
    y2[i] = mapa[y2[i]];
    y2[i]--;
    V[x1[i]].push_back(i);
    V[x2[i]].push_back(-i);
  }
  for (int i = 0; i < num; i++) {
    for (auto s : V[i])
      if (s < 0)
        usun(yy1[-s], y2[-s], -s);
      else
        dodaj(yy1[s], y2[s], s);
    while (ma[1] > 0) {
      odp[ma[1]] = 1;
      akt(ma[1]);
    }
  }
  int res = 1;
  for (int i = 1; i <= n; i++)
    if (odp[i] == 1) res++;
  cout << res;
  return 0;
}
