#include <bits/stdc++.h>
using namespace std;
bool sortinrev(const pair<long long, long long>& a,
               const pair<long long, long long>& b) {
  return (a.second > b.second);
}
int main() {
  long long n;
  cin >> n;
  long long x, y;
  vector<pair<long long, long long> > vec;
  vector<pair<long long, long long> > vec1;
  long long count = 0;
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    vec.push_back(make_pair(x, y));
    vec1.push_back(make_pair(x, y));
  }
  sort(vec.begin(), vec.end());
  long long max = vec[0].second;
  for (int i = 1; i < n; i++) {
    if (vec[i].second < max)
      count++;
    else
      max = vec[i].second;
  }
  cout << count << "\n";
  return 0;
}
