#include <bits/stdc++.h>
using namespace std;
pair<int, int> p[100050];
int N;
int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    p[i].first = a;
    p[i].second = b;
  }
  sort(p, p + N);
  int ans = 0;
  int rig = 0;
  for (int i = 0; i < N; i++) {
    if (p[i].second < rig)
      ans++;
    else
      rig = p[i].second;
  }
  cout << ans << endl;
  return 0;
}
