#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 500;
const long long mod = 1e9 + 7;
const long long INF = 1LL << 57;
const int M = 1e6 + 500;
bool vis[N];
void solve() {
  long long int n;
  cin >> n;
  long long int a[n], b[n];
  vector<pair<long long int, long long int> > v;
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
    v.push_back({a[i], b[i]});
  }
  sort(v.begin(), v.end());
  long long int mx = 0, ans = 0;
  for (int i = 0; i < n; i++) {
    if (mx > v[i].second)
      ans++;
    else
      mx = v[i].second;
  }
  cout << ans;
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int t;
  t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
