#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  vector<pair<int, int>> a;
  for (int i = 0; i < n; i++) {
    int t1, t2;
    scanf("%d %d", &t1, &t2);
    a.push_back(make_pair(t1, t2));
  }
  sort(a.begin(), a.end());
  int ans = 0, mx = a[0].second;
  for (int i = 1; i < n; i++) {
    if (a[i].second > mx)
      mx = a[i].second;
    else
      ans++;
  }
  cout << ans;
}
