#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n;
  cin >> n;
  vector<pair<long long int, long long int>> v;
  for (long long int i = 0; i < n; i++) {
    long long int x, y;
    cin >> x >> y;
    v.push_back({x, y});
  }
  sort(v.begin(), v.end());
  long long int ans = 0, s = v[0].second;
  for (long long int i = 1; i < n; i++) {
    if (s > v[i].second) ans++;
    s = max(s, v[i].second);
  }
  cout << ans;
  return 0;
}
