#include <iostream>
#include <utility>
#include <map>
#include <algorithm>

typedef std::pair<int, int> cable_t;
typedef std::vector<std::pair<cable_t, int>> cross_table_t;

bool less_than(std::pair<cable_t, int> const& p1,
               std::pair<cable_t, int> const& p2)
{
  return p1.second > p2.second;
}

bool crosses(cable_t const& c1, cable_t const& c2)
{
  if ((c1.first <= c2.first && c1.second > c2.second)
      || (c1.second < c2.second && c1.first >= c2.first))
    return true;
  
  return false;
}

bool calculate_crosses(cross_table_t& cr_t)
{
  bool done = true;
  for (auto it = cr_t.begin(); it != cr_t.end(); ++it) {
    it->second = 0;
    for (auto snd_it = cr_t.begin(); snd_it != cr_t.end(); ++snd_it)
      if (it != snd_it && crosses(it->first, snd_it->first))
        ++(it->second);

    if (it->second != 0)
      done = false;
  }
  return done;
}

int main()
{
  int n;
  std::cin >> n;
  
  cross_table_t cross_table;
  for (int i = 0; i < n; ++i) {
    int fst, snd;
    std::cin >> fst >> snd;
    
    cross_table.push_back(make_pair(cable_t(fst, snd), 0));
  }

  bool done;
  while (!(done = calculate_crosses(cross_table))) {
    std::sort(cross_table.begin(), cross_table.end(), less_than);
    cross_table.erase(cross_table.begin());
  }

  std::cout << cross_table.size() << std::endl;

  return 0;
}