#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int MAXN = 1e5 + 5;
const int T = 1001;
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};
int n;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed;
  cout.precision(10);
  int i, j, k, m;
  cin >> n;
  vector<pair<long long, long long> > date(n);
  for (i = 0; i < n; i++) cin >> date[i].first >> date[i].second;
  sort((date).begin(), (date).end());
  int late = 0, ans = 0;
  for (i = 0; i < n; i++) {
    if (date[i].second < late)
      ans++;
    else
      late = date[i].second;
  }
  cout << ans;
  return 0;
}
