#include <bits/stdc++.h>
using namespace std;
int ans;
pair<int, int> p[555555];
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  int x, y;
  for (int i = 1; i <= n; i++) cin >> x >> y, p[i] = make_pair(x, y);
  sort(p + 1, p + n + 1);
  int sum = 0, mx = 0;
  mx = p[1].second;
  for (int i = 2; i <= n; i++) {
    if (p[i].second < mx)
      sum++;
    else
      mx = p[i].second;
  }
  cout << sum;
  return 0;
}
