#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
pair<int, int> tab[100002];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> tab[i].first >> tab[i].second;
  sort(tab, tab + n);
  int maxi = tab[0].second, ans = 0;
  for (int i = 1; i < n; ++i) {
    if (tab[i].second < maxi)
      ans++;
    else
      maxi = tab[i].second;
  }
  cout << ans;
  return 0;
}
