#include <bits/stdc++.h>
using namespace std;
bool sortcol(const vector<long long int>& v1, const vector<long long int>& v2) {
  return (v1[0] < v2[0]);
}
int main() {
  long long int n;
  cin >> n;
  vector<vector<long long int>> v(n);
  for (long long int i = 0; i < n; i++) {
    long long int x, y;
    cin >> x >> y;
    v[i].push_back(x);
    v[i].push_back(y);
  }
  if (n == 1) {
    cout << 0 << endl;
    return 0;
  }
  sort(v.begin(), v.end(), sortcol);
  long long int cnt = 0, maxb = v[0][1];
  for (long long int i = 1; i < n; i++) {
    if (v[i][1] < maxb)
      cnt++;
    else if (maxb < v[i][1])
      maxb = v[i][1];
  }
  cout << cnt << endl;
  return 0;
}
