#include <bits/stdc++.h>
using namespace std;
struct node {
  int x;
  int y;
  int z;
} a[100001];
bool check(node A, node B) { return A.x < B.x; }
int b[100001];
int main() {
  cin.tie(NULL);
  int i, j, k, l, n, m;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i].x >> a[i].y;
    a[i].z = i;
  }
  sort(a, a + n, check);
  int maxi = -1, ans = 0;
  for (i = 0; i < n; i++) {
    if (a[i].y < maxi) ans++;
    maxi = max(maxi, a[i].y);
  }
  cout << ans;
  return 0;
}
